Waitress is an Alternative of Flask and Gunicorn for windows
November 8, 2018
‘Green Unicorn’ is a Python WSGI HTTP Server for UNIX. It helps your flask’s application to run on Production so that it will be easy to use.Waitress is an alternative for Guicorn
You can Setup Gunicorn by using the below command line to install:
$ pip install gunicorn
Windows does not support Gunicorn to work with the application
Refer the below link for more details,
So What’s the alternative of Gunicorn for Flask?
It has no dependencies except ones which live in the Python standard library. It runs on CPython on Unix and Windows under Python 2.7+ and Python 3.4+. It is also known to run on PyPy 1.6.0 on UNIX. It supports HTTP/1.0 and HTTP/1.1.
Hence the alternative of Gunicorn for flask is the Waitress
$ pip install waitress
Let us take an Example of Flask Code,
How to make waitress work with flask?
Consider the code below:
from flask import Flask app = Flask(__name__) @app.route("/") def hello(): return "Hello World!" if __name__ == "__main__": app.run()
Let’s write the updated code:
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=80)