-
-
Save LutzSteinborn/69f6284bc579646c74f59f1bf34f9008 to your computer and use it in GitHub Desktop.
Example of Tornado that autoreloads/watches all files in folder 'static'
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
Example of Tornado that autoreloads/watches all files in folder 'static' | |
''' | |
import tornado.ioloop | |
import tornado.web | |
import tornado.autoreload | |
import os | |
''' serves index.html''' | |
class MainHandler(tornado.web.RequestHandler): | |
def get(self): | |
self.render('static/index.html') | |
application = tornado.web.Application([ | |
(r'/', MainHandler), | |
(r'/static/(.*)', tornado.web.StaticFileHandler, {'path': 'static/'}) | |
],gzip=True) | |
if __name__ == "__main__": | |
application.listen(8888) | |
#TODO remove in prod | |
tornado.autoreload.start() | |
for dir, _, files in os.walk('static'): | |
[tornado.autoreload.watch(dir + '/' + f) for f in files if not f.startswith('.')] | |
tornado.ioloop.IOLoop.instance().start() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment