Reputation: 29
I run another gtk window to show my application, in the same time I want to run Flask.run(host:'0.0.0.0'). Flask still processing when I close my gtk.window that run my app. Can anybody help?
here is the code :
import multiprocessing
import opx
import app
def worker(file):
if file == 'opx':
opx.main()
else :
app.apx.run(host='0.0.0.0')
if __name__ == '__main__':
files = ["opx","app.py"]
for i in files:
p = multiprocessing.Process(target=worker(i))
p.start()
p.join()
Upvotes: 1
Views: 4424
Reputation: 1781
There are several combinations here:
from flask import Flask
from tornado.wsgi import WSGIContainer
from tornado.httpserver import HTTPServer
from tornado.ioloop import IOLoop
app = Flask(__name__)
@app.route("/")
def hello():
return "Hello World!"
if __name__ == "__main__":
http_server = HTTPServer(WSGIContainer(app))
http_server.listen(8000)
IOLoop.instance().start()
You should do more research before asked question. (Because of repeated problems can lead to confusion in the community)
Upvotes: 4