""" @author: luojunhui """ import time import json import uuid from quart import Blueprint, jsonify, request, websocket from applications.log import logging from applications.process import ProcessParams from applications.mq import MQ my_blueprint = Blueprint('kimi', __name__) @my_blueprint.route('/healthcheck') async def hello(): """ Hello World Test :return: """ logging( code="1001", info="请求接口成功", port="healthcheck" ) return jsonify({'message': 'Hello, World!'}) @my_blueprint.route('/title_to_video', methods=['POST']) async def post_data(): """ 请求接口代码 :return: """ trace_id = str(uuid.uuid4()) + "-" + str(int(time.time())) logging( code="1001", info="请求接口成功", port="title_to_video", trace_id=trace_id ) p = ProcessParams(t_id=trace_id) data = await request.get_json() processed_data = p.deal(data) return jsonify(processed_data) @my_blueprint.route('/search_videos', methods=['POST']) async def search_data(): """ 通过搜索词去搜索获取视频信息 :return: """ mq = MQ(topic_name="search_spider_prod") trace_id = "search-{}-{}".format(str(uuid.uuid4()), str(int(time.time()))) logging( code="1001", info="请求接口成功", port="search_videos", trace_id=trace_id ) data = await request.get_json() mq.send_msg(params=data) return jsonify({ "code": 0 })