借鉴: http://uwsgi-docs.readthedocs.org/en/latest/WSGIquickstart.html
1,下载并安装:
wget http://projects.unbit.it/downloads/uwsgi-latest.tar.gz tar zxvf uwsgi-latest.tar.gz cd <dir> make 2,Hello WorldLet’s start with a simple “Hello World” example (this is for Python 2.x, Python 3.x requires the returned string to be bytes, see lower):
def application(env, start_response): start_response('200 OK', [('Content-Type','text/html')]) return ["Hello World"](save it as foobar.py).
As you can see, it is composed of a single Python function. It is called “application” as this is default functionthat the uWSGI Python loader will search for (but you can obviously customize it).
The Python 3.x version is the following:
def application(env, start_response): start_response('200 OK', [('Content-Type','text/html')]) return [b"Hello World"]Deploy it on HTTP port 9090
Now start uWSGI to run an HTTP server/router passing requests to your WSGI application:
./uwsgi --http :9090 --wsgi-file foobar.py