From 6af0a0bbf9dcca5d5657806398fe2f96a86a5ef5 Mon Sep 17 00:00:00 2001 From: kaku Date: Sat, 6 Jul 2024 16:50:37 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E5=B0=86=E4=B8=A4=E4=B8=AA=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E7=AB=AF=E5=8F=A3=E5=88=86=E7=A6=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- conf/app.ini | 5 +++-- main.py | 35 ++++++++++++++++++++++++++--------- 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/conf/app.ini b/conf/app.ini index 93ce4b2..ca37592 100644 --- a/conf/app.ini +++ b/conf/app.ini @@ -1,6 +1,7 @@ [server] -port=8080 -debug=1 +port-web=8080 +port-api=8081 +debug=0 host=0.0.0.0 threaded=1 diff --git a/main.py b/main.py index 6961b6c..e1870c4 100644 --- a/main.py +++ b/main.py @@ -1,6 +1,7 @@ from flask import Flask import app_conf +import threading from web.api.receive import api_receive_bp from web.page import page_bp @@ -9,15 +10,31 @@ from web.page import page_bp conf = app_conf.conf() -app = Flask(__name__) -app.register_blueprint(page_bp) -app.register_blueprint(api_receive_bp) + +def runapp1(): + app1 = Flask(__name__) + app1.register_blueprint(page_bp) + app1.run( + debug=conf.getboolean("server", "debug"), + host=conf.get("server", "host"), + port=conf.get("server", "port-web"), + threaded=conf.getboolean("server", "threaded"), + ) +def runapp2(): + app2 = Flask(__name__) + app2.register_blueprint(api_receive_bp) + app2.run( + debug=conf.getboolean("server", "debug"), + host=conf.get("server", "host"), + port=conf.get("server", "port-api"), + threaded=conf.getboolean("server", "threaded"), + ) if __name__ == "__main__": - app.run( - debug=conf.getboolean("server", "debug"), - host=conf.get("server", "host"), - port=conf.get("server", "port"), - threaded=conf.getboolean("server", "threaded"), - ) + thread1 = threading.Thread(target=runapp1) + thread2 = threading.Thread(target=runapp2) + thread1.start() + thread2.start() + +