routes.py 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. """
  2. @author: luojunhui
  3. """
  4. from quart import Blueprint, jsonify, request
  5. from applications.functions import ParamProcess
  6. from applications.upload import *
  7. video_score_blueprint = Blueprint('light_gbm_score', __name__)
  8. @video_score_blueprint.route('/healthcheck')
  9. async def hello():
  10. """
  11. Hello World Test
  12. :return:
  13. """
  14. return jsonify({'message': 'Hello, World!'})
  15. @video_score_blueprint.route('/lightgbm_score', methods=['POST'])
  16. async def post_data():
  17. """
  18. 请求接口代码
  19. :return:
  20. """
  21. p = ParamProcess()
  22. data = await request.get_json()
  23. processed_data = await p.process(data)
  24. return jsonify(processed_data)
  25. @video_score_blueprint.route('/etl', methods=['POST'])
  26. async def download_upload_publish():
  27. """
  28. ETL Python 接口
  29. :return:
  30. """
  31. data = await request.get_json()
  32. video_id = data['video_id']
  33. video_url = data['video_url']
  34. video_title = data['video_title']
  35. result = await upload_to_oss(video_id=video_id, video_url=video_url)
  36. if result:
  37. upload_to_pq(oss_object_key=result, title=video_title)
  38. return jsonify({"status": "successfully uploaded"})
  39. else:
  40. return jsonify({"status": "failed"})