feat:将两个接口端口分离
This commit is contained in:
parent
ad761407b7
commit
6af0a0bbf9
@ -1,6 +1,7 @@
|
|||||||
[server]
|
[server]
|
||||||
port=8080
|
port-web=8080
|
||||||
debug=1
|
port-api=8081
|
||||||
|
debug=0
|
||||||
host=0.0.0.0
|
host=0.0.0.0
|
||||||
threaded=1
|
threaded=1
|
||||||
|
|
||||||
|
35
main.py
35
main.py
@ -1,6 +1,7 @@
|
|||||||
from flask import Flask
|
from flask import Flask
|
||||||
|
|
||||||
import app_conf
|
import app_conf
|
||||||
|
import threading
|
||||||
|
|
||||||
from web.api.receive import api_receive_bp
|
from web.api.receive import api_receive_bp
|
||||||
from web.page import page_bp
|
from web.page import page_bp
|
||||||
@ -9,15 +10,31 @@ from web.page import page_bp
|
|||||||
conf = app_conf.conf()
|
conf = app_conf.conf()
|
||||||
|
|
||||||
|
|
||||||
app = Flask(__name__)
|
|
||||||
app.register_blueprint(page_bp)
|
def runapp1():
|
||||||
app.register_blueprint(api_receive_bp)
|
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__":
|
if __name__ == "__main__":
|
||||||
app.run(
|
thread1 = threading.Thread(target=runapp1)
|
||||||
debug=conf.getboolean("server", "debug"),
|
thread2 = threading.Thread(target=runapp2)
|
||||||
host=conf.get("server", "host"),
|
thread1.start()
|
||||||
port=conf.get("server", "port"),
|
thread2.start()
|
||||||
threaded=conf.getboolean("server", "threaded"),
|
|
||||||
)
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user