I have written an application in Python/Flask which I need to deploy in production on a Windows Server(unfortunately). I came across a suggestion to use Waitress. It was a simple modification to make the web app use waitress, but my issues remain unsolved.
To server using waitress I have modified the code as below(just a basic example)
from flask import Flask
from waitress import serve
app = Flask(__name__)
@app.route('/')
def hello():
return 'Hello World!'
if __name__ == '__main__':
# app.run()
serve(app, host='0.0.0.0', port=8000)
Now I can run this from the command prompt via(same as without waitress)
python myapp.py
But I cannot use this in production.
If these two basic issues are not solvable then I wonder why waitress claims to be a production ready server:)
Waitress isn't responsible to init your server. It's just a way to activate WSGI
To init the service after restart just add to windows startup programs. Validate the server is up there are few ways to do so,the simple running a shell script that check the if the process up and execute it if not
I have just posted a answer to my own similar question here .
I think you will find that it answers this question too:-)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.