-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtornadows.py
38 lines (30 loc) · 1.12 KB
/
tornadows.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
# This Script was taken from
# https://github.com/mburst/burstolio/blob/master/tornadows.py
import os, sys
import django.core.handlers.wsgi
from tornado import httpserver, ioloop, wsgi, web
from optparse import OptionParser
parser = OptionParser()
parser.add_option('--port', dest='port')
options, args = parser.parse_args()
def runserver():
app_dir = os.path.abspath(os.path.dirname(__file__))
sys.path.append(os.path.dirname(app_dir))
os.environ['DJANGO_SETTINGS_MODULE'] = 'latech.settings'
wsgi_app = wsgi.WSGIContainer(django.core.handlers.wsgi.WSGIHandler())
settings = {
'auto_reload': True,
}
application = web.Application([
(r"/media/(.*)", web.StaticFileHandler, {"path": "./latech/media/"}),
(r"/static/(.*)", web.StaticFileHandler, {"path": "latech/static/"}),
(r".*", web.FallbackHandler, dict(fallback=wsgi_app)),
], **settings)
server = httpserver.HTTPServer(application)
server.listen(options.port)
try:
ioloop.IOLoop.instance().start()
except KeyboardInterrupt:
sys.exit(0)
if __name__ == '__main__':
runserver()