基于Nginx使用webpy框架操作代码,nginxwebpy,基于Nginx使用web


基于Nginx使用webpy框架操作代码分享,这是关于nginx下使用webpy框架简单小例子的python代码。这段代码的编程环境是ubuntu,需要flup。

Nginx 是什么:是一个高性能的HTTP和反向代理服务器,也是一个IMAP/POP3/SMTP服务器。

nginx--------------------------------------------------------server {        listen 80;        server_name new.vtao.net;        access_log /var/log/nginx/new.vtao.net.log;        location / {                include fastcgi_params;                fastcgi_pass unix:/tmp/py-fcgi.sock;        }        location /static/ {                root /var/webpy;                if (-f $request_filename){                        rewrite ^/static/(.*)$ /static/$1 break;                }        }}code.py--------------------------------------------------------#www.iplaypy.com#!/usr/bin/env pythonimport webimport datetimeurls=(        '/', 'index',)app=web.application(urls, globals())class index:        def GET(self):                return "Hello, world! now is:"+str(datetime.datetime.utcnow())if __name__=="__main__":        web.wsgi.runwsgi=lambda func,addr=None: web.wsgi.runfcgi(func,addr)        app.run()start shell script-------------------#!/bin/shspawn-fcgi -d /var/webpy -u www-data -g www-data -s /tmp/py-fcgi.sock -f /var/webpy/code.pystop shell script-------------------#!/bin/shkill `pgrep -f "python /var/webpy/code.py"`

编橙之家文章,

评论关闭