How do you run the Tornado web server locally?

python, tornado

Solution

Add an address argument to Application.listen() or HTTPServer.listen().

It's documented here (Application.listen) and here (TCPServer.listen).

For example:

application = tornado.web.Application([
    (r'/blah', BlahHandler),
    ], **settings)

# Create an HTTP server listening on localhost, port 8080.
http_server = tornado.httpserver.HTTPServer(application)
http_server.listen(8080, address='127.0.0.1')

Problem

Is it possible to run Tornado such that it listens to a local port (e.g. localhost:8000). I can't seem to find any documentation explaining how to do this.

Original source