代码拉取完成,页面将自动刷新
同步操作将从 xy/dr_py 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# File : app.py
# Author: DaShenHan&道长-----先苦后甜,任凭晚风拂柳颜------
# Date : 2022/9/6
from flask.app import Flask
from flask_migrate import Migrate
from base import config
from base.database import db
from utils.log import logger
from utils.system import get_wlan_info,getHost
from controllers import *
from js.rules import getRuleLists
import sys
def create_flask_app():
app = Flask(__name__, static_folder='static', static_url_path='/static')
app.config.from_object(config) # 单独的配置文件里写了,这里就不用弄json中文显示了
app.register_blueprint(home.home, url_prefix='')
app.register_blueprint(admin.admin, url_prefix='/admin')
app.register_blueprint(vod.vod, url_prefix='')
app.register_blueprint(cls.cls, url_prefix='/cls')
app.register_blueprint(layui.layui, url_prefix='/layui')
app.register_blueprint(parse.parse, url_prefix='/parse')
app.logger.name = "drLogger"
# lsg = service.storage_service()
logger.info(f"默认解析地址:{app.config.get('PLAY_URL')}")
# logger.info(f"自定义播放解析地址:{lsg.getItem('PLAY_URL')}")
logger.info(f'当前操作系统{sys.platform}')
rule_list = getRuleLists()
wlan_info,_ = get_wlan_info()
logger.info(rule_list)
logger.info(f'局域网: {getHost(1, app.config.get("HTTP_PORT"))}/index\n本地: {getHost(0, app.config.get("HTTP_PORT"))}/index\nwlan_info:{wlan_info}')
db.init_app(app)
db.app = app
db.create_all(app=app)
return app
app = create_flask_app()
migrate = Migrate(app, db)
now_python_ver = ".".join([str(i) for i in sys.version_info[:3]])
if sys.version_info < (3,9):
from gevent.pywsgi import WSGIServer
# from gevent import monkey
# monkey.patch_socket() # 开启socket异步
print(f'当前python版本{now_python_ver}为3.9.0及以下,支持gevent')
else:
print(f'当前python版本{now_python_ver}为3.9.0及以上,不支持gevent')
if __name__ == "__main__":
http_port = int(app.config.get('HTTP_PORT', 5705))
http_host = app.config.get('HTTP_HOST', '0.0.0.0')
if sys.version_info < (3, 9):
# server = WSGIServer(('0.0.0.0', 5705), app, handler_class=WebSocketHandler,log=app.logger)
# server = WSGIServer(('0.0.0.0', 5705), app, handler_class=WebSocketHandler,log=None)
server = WSGIServer((http_host, http_port), app, log=logger)
server.serve_forever()
else:
app.run(debug=False, host=http_host, port=http_port)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。