12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- """
- @author: luojunhui
- 投流--路由
- """
- import time
- import uuid
- from quart import Blueprint, jsonify, request
- from .insertVideoRoute import insert
- from .sourceIdRoute import saveSourceToDB
- from .recallPQVideos import recallPQVideos
- from deal import tempServer
- TL_blueprint = Blueprint("TouLiu", __name__)
- def Routes(db_client):
- """
- 路由代码
- :param db_client: 异步db连接池
- :return:
- """
- @TL_blueprint.route("/hello")
- def helloWorld():
- """
- :return: Hello World
- """
- return jsonify({"message": "Hello World!"})
- @TL_blueprint.route("/generateInfo", methods=['POST'])
- async def generateInfo():
- """
- 生成一些需要用到到信息
- :return:
- """
- request_id = "generateInfo_{}_{}".format(uuid.uuid4(), int(time.time()))
- data = await request.get_json()
- response = await saveSourceToDB(
- db_client=db_client,
- params=data,
- request_id=request_id
- )
- return jsonify(response)
- @TL_blueprint.route("/insertVideo", methods=['POST'])
- async def insertVideos():
- """
- 插入视频信息
- :return:
- """
- request_id = "insertVideos_{}_{}".format(uuid.uuid4(), int(time.time()))
- data = await request.get_json()
- response = await insert(
- db_client=db_client,
- params=data,
- request_id=request_id
- )
- return jsonify(response)
- @TL_blueprint.route("/recallPQVideos", methods=['POST'])
- async def recallVideos():
- """
- 搜索视频信息
- :return:
- """
- request_id = "recallPQVideos_{}_{}".format(uuid.uuid4(), int(time.time()))
- data = await request.get_json()
- response = await recallPQVideos(
- db_client=db_client,
- params=data,
- request_id=request_id
- )
- return jsonify(response)
- @TL_blueprint.route("/VideoRank", methods=['POST'])
- async def ranks():
- """
- :return:
- """
- # request_id = "videoRank_{}_{}".format(uuid.uuid4(), int(time.time()))
- data = await request.get_json()
- gh_id = data['ghId']
- ts = tempServer(gh_id=gh_id)
- response = ts.chooseCards()
- return jsonify(response)
- return TL_blueprint
|