Tornado Web Server

From Code Self Study Wiki
Jump to: navigation, search

Tornado web framework.

Routing

import tornado.web
class GetUserByIdHandler(tornado.web.RequestHandler):
    # Choose a method
    def get(self, id):
        response = {
            'id': int(id),
            'name': 'Arthur',
            'profession': 'Astronaut'
        }
        # Automatically returns dicts as JSON
        self.write(response)