-
Notifications
You must be signed in to change notification settings - Fork 3
/
server.py
executable file
·36 lines (30 loc) · 895 Bytes
/
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
35
36
#!/usr/bin/env python
import tornado.ioloop
import tornado.web
import json
from tornado.options import options, define
from tornado.autoreload import watch
from jinja2 import Environment, FileSystemLoader
env = Environment(loader=FileSystemLoader('templates'))
class MainHandler(tornado.web.RequestHandler):
def get(self):
template = env.get_template('index.html')
self.write(template.render({
'assets': options.ASSETS
}))
application = tornado.web.Application([
(r"/", MainHandler),
], static_path='static', debug=True)
if __name__ == "__main__":
try:
fn = 'webpack-assets.json'
with open(fn) as f:
watch(fn)
assets = json.load(f)
except IOError:
pass
except KeyError:
pass
define('ASSETS', assets)
application.listen(8888)
tornado.ioloop.IOLoop.current().start()