__init__.py 1.2 KB

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