__init__.py 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. TL_blueprint = Blueprint("TouLiu", __name__)
  11. def Routes(db_client):
  12. """
  13. 路由代码
  14. :param db_client: 异步db连接池
  15. :return:
  16. """
  17. @TL_blueprint.route("/hello")
  18. def helloWorld():
  19. """
  20. :return: Hello World
  21. """
  22. return jsonify({"message": "Hello World!"})
  23. @TL_blueprint.route("/generateInfo", methods=['POST'])
  24. async def generateInfo():
  25. """
  26. 生成一些需要用到到信息
  27. :return:
  28. """
  29. request_id = "generateInfo_{}_{}".format(uuid.uuid4(), int(time.time()))
  30. data = await request.get_json()
  31. response = await saveSourceToDB(
  32. db_client=db_client,
  33. params=data,
  34. request_id=request_id
  35. )
  36. return jsonify(response)
  37. @TL_blueprint.route("/insertVideo", methods=['POST'])
  38. async def insertVideos():
  39. """
  40. 插入视频信息
  41. :return:
  42. """
  43. request_id = "insertVideos_{}_{}".format(uuid.uuid4(), int(time.time()))
  44. data = await request.get_json()
  45. response = await insert(
  46. db_client=db_client,
  47. params=data,
  48. request_id=request_id
  49. )
  50. return jsonify(response)
  51. return TL_blueprint