__init__.py 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. """
  2. @author: luojunhui
  3. 投流--路由
  4. """
  5. import time
  6. import uuid
  7. from quart import Blueprint, jsonify, request
  8. from .insertVideoRoute import insert
  9. from .sourceIdRoute import saveSourceToDB
  10. from .recallPQVideos import recallPQVideos
  11. TL_blueprint = Blueprint("TouLiu", __name__)
  12. def Routes(db_client):
  13. """
  14. 路由代码
  15. :param db_client: 异步db连接池
  16. :return:
  17. """
  18. @TL_blueprint.route("/hello")
  19. def helloWorld():
  20. """
  21. :return: Hello World
  22. """
  23. return jsonify({"message": "Hello World!"})
  24. @TL_blueprint.route("/generateInfo", methods=['POST'])
  25. async def generateInfo():
  26. """
  27. 生成一些需要用到到信息
  28. :return:
  29. """
  30. request_id = "generateInfo_{}_{}".format(uuid.uuid4(), int(time.time()))
  31. data = await request.get_json()
  32. response = await saveSourceToDB(
  33. db_client=db_client,
  34. params=data,
  35. request_id=request_id
  36. )
  37. return jsonify(response)
  38. @TL_blueprint.route("/insertVideo", methods=['POST'])
  39. async def insertVideos():
  40. """
  41. 插入视频信息
  42. :return:
  43. """
  44. request_id = "insertVideos_{}_{}".format(uuid.uuid4(), int(time.time()))
  45. data = await request.get_json()
  46. response = await insert(
  47. db_client=db_client,
  48. params=data,
  49. request_id=request_id
  50. )
  51. return jsonify(response)
  52. @TL_blueprint.route("/recallPQVideos", methods=['POST'])
  53. async def recallVideos():
  54. """
  55. 搜索视频信息
  56. :return:
  57. """
  58. request_id = "recallPQVideos_{}_{}".format(uuid.uuid4(), int(time.time()))
  59. data = await request.get_json()
  60. response = await recallPQVideos(
  61. db_client=db_client,
  62. params=data,
  63. request_id=request_id
  64. )
  65. return jsonify(response)
  66. return TL_blueprint