-
Notifications
You must be signed in to change notification settings - Fork 5
/
runwsgi.py
65 lines (48 loc) · 1.73 KB
/
runwsgi.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
PORT = 8000
HOST = '0.0.0.0'
import sys
server, appname = sys.argv[1:]
if appname == 'bottle':
from servers.bot import app
elif appname == 'flask':
from servers.fla import app
elif appname == 'pyramid':
from servers.pyr import app
if __name__ == "__main__":
if server == 'gevent':
from gevent.wsgi import WSGIServer
http_server = WSGIServer((HOST, PORT), app, log=None)
http_server.serve_forever()
elif server == 'tornado':
from tornado.wsgi import WSGIContainer
from tornado.httpserver import HTTPServer
from tornado.ioloop import IOLoop
http_server = HTTPServer(WSGIContainer(app))
http_server.listen(PORT)
IOLoop.instance().start()
elif server == 'eventlet':
from eventlet import wsgi
import eventlet
wsgi.server(eventlet.listen(('127.0.0.1', PORT), backlog=500), app, log=file('/dev/null', 'w'))
elif server == 'cherrypy':
from cherrypy import wsgiserver
server = wsgiserver.CherryPyWSGIServer(
(HOST, PORT), app,
server_name='www.cherrypy.example')
server.start()
elif server == 'rocket':
from rocket import Rocket
server = Rocket((HOST, PORT), 'wsgi', {"wsgi_app":app})
server.start()
elif server == 'paste':
from paste import httpserver
httpserver.serve(app, host=HOST, port=PORT)
elif server == 'twisted':
from twisted.web.server import Site
from twisted.web.wsgi import WSGIResource
from twisted.internet import reactor
resource = WSGIResource(reactor, reactor.getThreadPool(), app)
reactor.listenTCP(PORT,Site(resource))
reactor.run()
else:
raise Exception('wat')