Skip to content

Instantly share code, notes, and snippets.

@mondeja
Forked from cjgiridhar/articles.html
Created November 12, 2017 19:58
Show Gist options
  • Save mondeja/4cc24df5037c29d518be500d165176e0 to your computer and use it in GitHub Desktop.
Save mondeja/4cc24df5037c29d518be500d165176e0 to your computer and use it in GitHub Desktop.
Tornado - Static File Handler
<html>
<title>
Articles
</title>
<body>
<h1>Articles page</h1>
<p><img src="images/images.jpg"/></p>
</body>
</html>
import tornado.ioloop
import tornado.web
import time
class ItWorks(tornado.web.RequestHandler):
def get(self):
self.write("It Works!!")
class Article(tornado.web.RequestHandler):
def get(self):
self.render('articles.html')
application = tornado.web.Application([
(r"/", ItWorks),
(r"/articles", Article),
(r"/images/(.*)",tornado.web.StaticFileHandler, {"path": "./images"},),
(r"/images/(style.\css)",tornado.web.StaticFileHandler, {"path": "./images/css"},),
],debug=True)
if __name__ == "__main__":
application.listen(8888)
tornado.ioloop.IOLoop.instance().start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment