📅  最后修改于: 2023-12-03 15:31:05.310000             🧑  作者: Mango
Gunicorn is a popular Python WSGI HTTP Server for UNIX systems. However, it is also possible to run Gunicorn on Windows. In this article, we will explore the steps required to install and use Gunicorn on Windows.
python -m ensurepip
pip install virtualenv
virtualenv myenv
.\myenv\Scripts\activate
pip install gunicorn
To run Gunicorn, you need to create a Python WSGI application. This can be done in a separate file, for example app.py
, as shown below:
def app(environ, start_response):
status = '200 OK'
headers = [('Content-type', 'text/plain')]
response_body = 'Hello, World!'
start_response(status, headers)
return [response_body.encode()]
Next, you can start Gunicorn by running the following command:
gunicorn app:app
This will start Gunicorn and listen on the default port 8000. You can access your application by opening a web browser and navigating to http://localhost:8000.
In this article, we have explored the steps required to install and use Gunicorn on Windows. By following these steps, you can now run Python WSGI applications on Windows using Gunicorn.