📝 Edit page
➕ Add page
uWSGI
Byline:
uWSGI application server container
Key links
- 🏠 Homepage: https://uwsgi-docs.readthedocs.io
- 👨💻 Repo:
The uWSGI project aims at developing a full stack for building hosting services.
It is built around the WSGI standard for Python web apps.
Install
Get C compilers like gcc
or clang
and Python dev headers. On Debian-based systems:
$ sudo apt-get install build-essential python-dev
$ pip install uwsgi
Hello world
From WSGI Quickstart.
Set up a function to return a message in bytes with 200 OK HTTP code.
foobar.py
def application(env, start_response): start_response('200 OK', [ ('Content-Type','text/html') ]) return [b"Hello World"]
Deploy
Deploy the app:
$ uwsgi --http :9090 --wsgi-file foobar.py
Do not use
--http
when you have a frontend webserver or you are doing some form of benchmark, use--http-socket
.
See the docs for how to configure for Flask or Django.
Concurrency and monitoring
$ uwsgi --http :9090 --wsgi-file foobar.py --master \
--processes 4 \
--threads 2
$ uwsgi --http :9090 --wsgi-file foobar.py --master \
--processes 4 \
--threads 2 \
--stats 127.0.0.1:9191
Configure with Nginx
location / {
include uwsgi_params;
uwsgi_pass 127.0.0.1:3031;
}
$ uwsgi --socket 127.0.0.1:3031 \
--wsgi-file foobar.py --master \
--processes 4 --threads 2 --stats 127.0.0.1:9191