-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathexample.py
More file actions
25 lines (20 loc) · 714 Bytes
/
example.py
File metadata and controls
25 lines (20 loc) · 714 Bytes
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
"""A tiny application using tornado_xstatic
You need the XStatic-jQuery package installed as well.
"""
import tornado.ioloop
import tornado.web
from tornado_xstatic import XStaticFileHandler, xstatic_url
class MyHandler(tornado.web.RequestHandler):
def get(self):
self.render("eg_template.html")
if __name__ == "__main__":
application = tornado.web.Application(
[
(r"/", MyHandler),
(r"/xstatic/(.*)", XStaticFileHandler, {"allowed_modules": ["jquery"]}),
],
ui_methods={'xstatic': xstatic_url('/xstatic/')}
)
application.listen(8888)
print("Open http://localhost:8888/ in your browser")
tornado.ioloop.IOLoop.instance().start()