fix 修改flask启动方式
This commit is contained in:
parent
6a3d0797fb
commit
fcab5ad5e1
@ -29,7 +29,7 @@ from .local_server import ls_api
|
|||||||
from pywxdump import __version__
|
from pywxdump import __version__
|
||||||
|
|
||||||
|
|
||||||
def gen_fastapi_app(handler):
|
def gen_fastapi_app(handler, origins=None):
|
||||||
app = FastAPI(title="wxdump", description="微信工具", version=__version__,
|
app = FastAPI(title="wxdump", description="微信工具", version=__version__,
|
||||||
terms_of_service="https://github.com/xaoyaoo/pywxdump",
|
terms_of_service="https://github.com/xaoyaoo/pywxdump",
|
||||||
contact={"name": "xaoyaoo", "url": "https://github.com/xaoyaoo/pywxdump"},
|
contact={"name": "xaoyaoo", "url": "https://github.com/xaoyaoo/pywxdump"},
|
||||||
@ -37,15 +37,15 @@ def gen_fastapi_app(handler):
|
|||||||
"url": "https://github.com/xaoyaoo/PyWxDump/blob/master/LICENSE"})
|
"url": "https://github.com/xaoyaoo/PyWxDump/blob/master/LICENSE"})
|
||||||
|
|
||||||
web_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), "ui", "web") # web文件夹路径
|
web_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), "ui", "web") # web文件夹路径
|
||||||
|
|
||||||
# 跨域
|
# 跨域
|
||||||
origins = [
|
if not origins:
|
||||||
"http://localhost:5000",
|
origins = [
|
||||||
"http://127.0.0.1:5000",
|
"http://localhost:5000",
|
||||||
"http://localhost:8080", # 开发环境的客户端地址"
|
"http://127.0.0.1:5000",
|
||||||
# "http://0.0.0.0:5000",
|
"http://localhost:8080", # 开发环境的客户端地址"
|
||||||
# "*"
|
# "http://0.0.0.0:5000",
|
||||||
]
|
# "*"
|
||||||
|
]
|
||||||
app.add_middleware(
|
app.add_middleware(
|
||||||
CORSMiddleware,
|
CORSMiddleware,
|
||||||
allow_origins=origins, # 允许所有源
|
allow_origins=origins, # 允许所有源
|
||||||
@ -191,10 +191,17 @@ def start_server(port=5000, online=False, debug=False, isopenBrowser=True,
|
|||||||
|
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
server_loger.info(f"启动flask服务,host:port:{host}:{port}")
|
server_loger.info(f"启动flask服务,host:port:{host}:{port}")
|
||||||
print("[+] 请使用浏览器访问 http://127.0.0.1:5000/ 查看聊天记录")
|
print(f"[+] 请使用浏览器访问 http://127.0.0.1:{port}/ 查看聊天记录")
|
||||||
global app
|
global app
|
||||||
print("[+] 如需查看api文档,请访问 http://127.0.0.1:5000/docs ")
|
print(f"[+] 如需查看api文档,请访问 http://127.0.0.1:{port}/docs ")
|
||||||
app = gen_fastapi_app(file_handler)
|
origins = [
|
||||||
|
f"http://localhost:{port}",
|
||||||
|
f"http://{host}:{port}",
|
||||||
|
f"http://localhost:8080", # 开发环境的客户端地址"
|
||||||
|
# f"http://0.0.0.0:{port}",
|
||||||
|
# "*"
|
||||||
|
]
|
||||||
|
app = gen_fastapi_app(file_handler, origins)
|
||||||
|
|
||||||
LOGGING_CONFIG["formatters"]["default"]["fmt"] = "[%(asctime)s] %(levelprefix)s %(message)s"
|
LOGGING_CONFIG["formatters"]["default"]["fmt"] = "[%(asctime)s] %(levelprefix)s %(message)s"
|
||||||
LOGGING_CONFIG["formatters"]["access"][
|
LOGGING_CONFIG["formatters"]["access"][
|
||||||
|
Loading…
Reference in New Issue
Block a user