Skip to content

Instantly share code, notes, and snippets.

@kjoconnor
Created July 9, 2014 16:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kjoconnor/5a227a732202eb20aac6 to your computer and use it in GitHub Desktop.
Save kjoconnor/5a227a732202eb20aac6 to your computer and use it in GitHub Desktop.
Create a redirect loop with Tornado (for testing)
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