WSGI学习系列多种方式创建WebServer

def application(environ, start_response):
    start_response('200 OK', [('Content-Type', 'text/html')])
    return '<h1>Hello, web!</h1>'


# 1st
# Just for Test and it is single thread
from wsgiref.simple_server import make_server
httpd = make_server('', 8000, application)
httpd.serve_forever()

# 2nd
# Use paste httpserver
from paste import httpserver
httpserver.serve(application, host='127.0.0.1', port=8000)

# 3rd
# Use eventlet
import eventlet from eventlet import wsgi wsgi.server(eventlet.listen(('', 8000)), application) print "Serving HTTP on port 8000..."

 

posted @ 2015-08-04 16:36  Edisonxiang  阅读(327)  评论(0编辑  收藏  举报