""" @author: luojunhui """ import time import uuid from quart import Blueprint, jsonify, request from applications.log import logging from applications.process import ProcessParams 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.process(data) return jsonify(processed_data) @my_blueprint.route('/search_videos', methods=['POST']) async def search_data(): """ 通过搜索词去搜索获取视频信息 :return: """ 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() result = await search_spider(data) return jsonify(result)