uwsgi安装和测试

来源:互联网 发布:matlab分水岭算法函数 编辑:程序博客网 时间:2024/05/16 06:04

借鉴: http://uwsgi-docs.readthedocs.org/en/latest/WSGIquickstart.html

1,下载并安装:

wget http://projects.unbit.it/downloads/uwsgi-latest.tar.gztar zxvf uwsgi-latest.tar.gzcd <dir>make2,Hello World

Let’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

0 0
原创粉丝点击