Created
July 30, 2012 05:30
-
-
Save cjgiridhar/3205067 to your computer and use it in GitHub Desktop.
Tornado - Static File Handler
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
<html> | |
<title> | |
Articles | |
</title> | |
<body> | |
<h1>Articles page</h1> | |
<p><img src="images/images.jpg"/></p> | |
</body> | |
</html> |
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
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