Created
July 9, 2014 16:01
-
-
Save kjoconnor/5a227a732202eb20aac6 to your computer and use it in GitHub Desktop.
Create a redirect loop with Tornado (for testing)
This file contains hidden or 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.httpserver | |
import tornado.ioloop | |
import tornado.web | |
PORT = 10045 | |
class Application(tornado.web.Application): | |
def __init__(self): | |
handlers = [ | |
(r'/redirect', RedirectHandler) | |
] | |
tornado.web.Application.__init__(self, handlers, debug=True) | |
class RedirectHandler(tornado.web.RequestHandler): | |
def get(self): | |
self.redirect('http://localhost:{port}/redirect'.format(port=PORT)) | |
if __name__ == '__main__': | |
http_server = tornado.httpserver.HTTPServer(Application()) | |
http_server.listen(PORT) | |
tornado.ioloop.IOLoop.instance().start() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment