-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdjrs_server.py
34 lines (26 loc) · 974 Bytes
/
djrs_server.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
# dependancies for this server.
import os, sys
import django.core.handlers.wsgi
from tornado import httpserver, ioloop, wsgi
from tornado.web import Application, StaticFileHandler, FallbackHandler
import djrs_path
#from djrs_path import app_dir
os.environ['DJANGO_SETTINGS_MODULE'] = 'djrs.settings'
# explicit dependencies for django + app.
import djrs_deps
def runserver():
#static_path = os.path.join(app_dir, 'static')
static_path = os.path.join('.', 'static')
wsgi_app = wsgi.WSGIContainer(django.core.handlers.wsgi.WSGIHandler())
tornado_app = Application([
(r'/static/(.*)', StaticFileHandler, {'path': static_path}),
('.*', FallbackHandler, dict(fallback=wsgi_app)),
])
server = httpserver.HTTPServer(tornado_app)
server.listen(8000)
try:
ioloop.IOLoop.instance().start()
except KeyboardInterrupt:
sys.exit(0)
if __name__ == '__main__':
runserver()