Skip to content

Instantly share code, notes, and snippets.

@lbolla
Last active September 6, 2019 19:32
Show Gist options
  • Save lbolla/501ebba48f343dc530fb5e88af97c3f3 to your computer and use it in GitHub Desktop.
Save lbolla/501ebba48f343dc530fb5e88af97c3f3 to your computer and use it in GitHub Desktop.
# Run the server with:
# $> newrelic-admin run-python newrelic-tornado6.py --logging=debug
# Hit the server with:
# $> curl http://localhost:8888/
# Note the error in the server logs
import tornado.httpclient
import tornado.ioloop
from tornado.options import parse_command_line
import tornado.web
# URL that returns a redirect code, e.g. 302
url = "http://httpbin.org/redirect-to?url=http%3A%2F%2Fwww.google.com&status_code=302"
class MainHandler(tornado.web.RequestHandler):
async def get(self):
c = tornado.httpclient.AsyncHTTPClient()
r = await c.fetch(url)
self.write(r.body)
if __name__ == "__main__":
parse_command_line()
application = tornado.web.Application([
(r"/", MainHandler),
], debug=True)
application.listen(8888)
tornado.ioloop.IOLoop.current().start()
@lbolla
Copy link
Author

lbolla commented Sep 6, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment