Skip to content

Instantly share code, notes, and snippets.

@ramhiser
Created October 12, 2015 18:13
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 ramhiser/745db53bc54340343d56 to your computer and use it in GitHub Desktop.
Save ramhiser/745db53bc54340343d56 to your computer and use it in GitHub Desktop.
Simple Tornado server example
import tornado
import tornado.ioloop
import tornado.web
from tornado.httpclient import AsyncHTTPClient
class MainHandler(tornado.web.RequestHandler):
@gen.coroutine
def get(self):
http = AsyncHTTPClient(method="POST")
print http
response = yield http.fetch("http://google.com")
print response
self.write("Num Bytes Fetched from Google: " + str(len(response.body)))
def make_app():
return tornado.web.Application([
(r"/", MainHandler),
])
app = make_app()
app.listen(8888)
tornado.ioloop.IOLoop.current().start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment