routes.py 958 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. """
  2. @author: luojunhui
  3. """
  4. import time
  5. import uuid
  6. from quart import Blueprint, jsonify, request
  7. from applications.log import logging
  8. from applications.process import ProcessParams
  9. my_blueprint = Blueprint('kimi', __name__)
  10. @my_blueprint.route('/healthcheck')
  11. async def hello():
  12. """
  13. Hello World Test
  14. :return:
  15. """
  16. logging(
  17. code="1001",
  18. info="请求接口成功",
  19. port="healthcheck"
  20. )
  21. return jsonify({'message': 'Hello, World!'})
  22. @my_blueprint.route('/title_to_video', methods=['POST'])
  23. async def post_data():
  24. """
  25. 请求接口代码
  26. :return:
  27. """
  28. trace_id = str(uuid.uuid4()) + "-" + str(int(time.time()))
  29. logging(
  30. code="1001",
  31. info="请求接口成功",
  32. port="title_to_video",
  33. trace_id=trace_id
  34. )
  35. p = ProcessParams(t_id=trace_id)
  36. data = await request.get_json()
  37. processed_data = p.process(data)
  38. return jsonify(processed_data)