You've already forked Douyin_Web_Live
api支持
This commit is contained in:
68
core/controller/manager_blueprint.py
Normal file
68
core/controller/manager_blueprint.py
Normal file
@ -0,0 +1,68 @@
|
||||
from flask import Blueprint, request, jsonify
|
||||
|
||||
from core import CoreManager
|
||||
|
||||
blueprint = Blueprint("api_manager", __name__, url_prefix="/api/manager")
|
||||
|
||||
c = CoreManager()
|
||||
|
||||
|
||||
@blueprint.post("/on_broadcast")
|
||||
def on_broadcast():
|
||||
form = request.form
|
||||
if "room_id" in form:
|
||||
c.on_broadcast(room_id=form['room_id'])
|
||||
return jsonify(
|
||||
message="OK",
|
||||
code=0,
|
||||
success=True,
|
||||
data=None
|
||||
)
|
||||
else:
|
||||
return jsonify(
|
||||
message="Missing Param [room_id]",
|
||||
code=403,
|
||||
success=False,
|
||||
data=None
|
||||
)
|
||||
|
||||
|
||||
@blueprint.post("/open_url")
|
||||
def open_url():
|
||||
form = request.form
|
||||
if "url" in form:
|
||||
c.open_tab(form['url'])
|
||||
return jsonify(
|
||||
message="OK",
|
||||
code=0,
|
||||
success=True,
|
||||
data=None
|
||||
)
|
||||
else:
|
||||
return jsonify(
|
||||
message="Missing Param [room_id]",
|
||||
code=403,
|
||||
success=False,
|
||||
data=None
|
||||
)
|
||||
|
||||
|
||||
@blueprint.get("/config")
|
||||
def get_config():
|
||||
return jsonify(
|
||||
message="OK",
|
||||
code=0,
|
||||
success=True,
|
||||
data=c.config_manager.config,
|
||||
)
|
||||
|
||||
|
||||
@blueprint.post("/config")
|
||||
def write_config():
|
||||
c.config_manager.save_config()
|
||||
return jsonify(
|
||||
message="OK",
|
||||
code=0,
|
||||
success=True,
|
||||
data=None
|
||||
)
|
@ -61,6 +61,7 @@ class CoreManager(metaclass=Singleton):
|
||||
_log.info("初始化浏览器管理器完毕")
|
||||
_log.debug("初始化输出管理器")
|
||||
self.output_manager = OutputManager(self.config_manager)
|
||||
self.output_manager.start_loop()
|
||||
_log.info("初始化输出管理器完毕")
|
||||
self._open_config_tabs()
|
||||
|
||||
|
Reference in New Issue
Block a user