123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- """
- @author: luojunhui
- 投流--路由
- """
- import time
- import uuid
- from quart import Blueprint, jsonify, request
- from .insertVideoRoute import insert
- from .sourceIdRoute import saveSourceToDB
- 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)
- return TL_blueprint
|