1. Home
  2. /
  3. Tornado
  4. /
  5. Route Parameter Example

Route Parameter Example - Tornado Typing CST Test

Loading…

Route Parameter Example — Tornado Code

Returns user info based on URL parameter.

import tornado.ioloop
import tornado.web

class UserHandler(tornado.web.RequestHandler):
	async def get(self, user_id):
		self.write({'id': int(user_id), 'name': f'User {user_id}'})

app = tornado.web.Application([
	(r'/users/(\d+)', UserHandler)
])

if __name__ == '__main__':
	app.listen(8888)
	tornado.ioloop.IOLoop.current().start()

Tornado Language Guide

Tornado is a Python web framework and asynchronous networking library, designed for handling thousands of simultaneous connections. It excels at real-time web services and long-lived network connections.

Primary Use Cases

  • ▸Real-time chat applications
  • ▸WebSocket-based dashboards
  • ▸High-concurrency APIs and services
  • ▸Long-polling or streaming data endpoints
  • ▸IoT backends and notification services

Notable Features

  • ▸Asynchronous, non-blocking I/O
  • ▸Integrated web framework and networking library
  • ▸Native WebSocket support
  • ▸High concurrency for thousands of clients
  • ▸Flexible request handling with coroutines

Origin & Creator

Tornado was created by FriendFeed engineers (Brett Slatkin, David Cournapeau, and others) in 2009, later maintained by Facebook and the open-source community.

Industrial Note

Tornado is preferred for real-time web services, WebSocket servers, and high-concurrency applications where traditional WSGI frameworks may struggle.

More Tornado Typing Exercises

Tornado Simple Counter APITornado Hello World APITornado JSON EchoTornado Query Parameter ExampleTornado Middleware LoggingTornado Async Delay ExampleTornado 404 ExampleTornado Combined Routes Example

Practice Other Languages

CReactPythonC++RustTypeScriptKotlinPHPJavaC#RubyMqlCqlN1qlCypher