routes.py 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. """
  2. @author: luojunhui
  3. """
  4. from quart import Blueprint, jsonify, request
  5. from applications.deal import Response, Record, Minigram, GetOffVideos
  6. my_blueprint = Blueprint('LongArticles', __name__)
  7. def Routes(mysql_client):
  8. """
  9. 路由代码
  10. """
  11. @my_blueprint.route('/healthcheck')
  12. def healthcheck():
  13. """
  14. Hello World Test
  15. :return:
  16. """
  17. return jsonify({'message': 'Hello, World!'})
  18. @my_blueprint.route('/search_videos', methods=['POST'])
  19. async def search_videos_from_the_web():
  20. """
  21. 从web 搜索视频并且存储到票圈的视频库中
  22. :return:
  23. """
  24. params = await request.get_json()
  25. SD = Record(params=params, mysql_client=mysql_client)
  26. result = await SD.deal()
  27. return jsonify(result)
  28. @my_blueprint.route('/recall_videos', methods=['POST'])
  29. async def recall_results():
  30. """
  31. 获取视频分享卡片
  32. :return:
  33. """
  34. data = await request.get_json()
  35. trace_id = data['traceId']
  36. minigram_type = data['miniprogramUseType']
  37. strategy = data.get('strategy')
  38. if strategy:
  39. RD = Response(trace_id=trace_id, mini_program_type=minigram_type, mysql_client=mysql_client, strategy=strategy)
  40. else:
  41. RD = Response(trace_id=trace_id, mini_program_type=minigram_type, mysql_client=mysql_client)
  42. response = await RD.deal()
  43. return jsonify(response)
  44. @my_blueprint.route("/choose_minigram", methods=['POST'])
  45. async def match_minigram():
  46. """
  47. 获取小程序信息
  48. :return:
  49. """
  50. data = await request.get_json()
  51. M = Minigram(params=data)
  52. response = await M.deal()
  53. return jsonify(response)
  54. @my_blueprint.route("/get_off_videos", methods=['POST'])
  55. async def get_off_videos():
  56. """
  57. 自动下架视频记录
  58. :return:
  59. """
  60. data = await request.get_json()
  61. GOV = GetOffVideos(params=data, mysql_client=mysql_client)
  62. response = await GOV.deal()
  63. return jsonify(response)
  64. return my_blueprint