Middleware support for Tornado Framework
Project description
Tornado Middlewares
Middleware support for Tornado Framework
Install
pip install tornado-middleware
Example
Create a simple middleware on RequestHandler class.
from tornado_middleware import MiddlewareHandler
class IndexHandler(MiddlewareHandler):
async def middleware_echo(self, next):
print("Middleware triggered")
await next()
def get(self):
print("Function triggered")
self.set_status(200)
self.finish("<html><body><h1>Hello Middleware</h1></body></html>")
Create a separately middleware
from tornado_middleware import MiddlewareHandler
from tornado.web import RequestHandler
class EchoMiddleware(MiddlewareHandler):
async def middleware_echo(self, next):
print("Middleware triggered")
await next()
class IndexHandler(EchoMiddleware, RequestHandler):
def get(self):
print("Function triggered")
self.set_status(200)
self.finish("<html><body><h1>Hello Middleware</h1></body></html>")
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tornado-middleware-1.2.3.tar.gz.
File metadata
- Download URL: tornado-middleware-1.2.3.tar.gz
- Upload date:
- Size: 4.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
72f3649d2125918e83f251278ddfb98cf6ee5c1090eec91a241aa52c597278e0
|
|
| MD5 |
331f117d277cda2801601afc590473d1
|
|
| BLAKE2b-256 |
5566496d1d79c242f88229f26546a358fe4bc30903189242d6c32057336ff6d3
|
File details
Details for the file tornado_middleware-1.2.3-py3-none-any.whl.
File metadata
- Download URL: tornado_middleware-1.2.3-py3-none-any.whl
- Upload date:
- Size: 4.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2c055c0b1327824646594d7a906dfb149167f2981480aba692ca221ae07b52e5
|
|
| MD5 |
e7b4e24a796bbd096ed77487e062791e
|
|
| BLAKE2b-256 |
f72590edb4928d9d29300d8609ce8963073ec62d19d7056658e77fb998a79337
|