TMiddleware
Middleware for tornado
[](https://travis-ci.org/iamsk/tmiddleware)
## Installation
pip install tmiddleware
or
git clone git@github.com:iamsk/tmiddleware.git cd tmiddleware python setup.py install
## Requirements
python 2.6 or 2.7
tornado 2.4+
## Minimal Demo
### $ more examples/miminal.py
import tornado import tornado.httpserver from tornado.options import define, options from tornado.web import RequestHandler
from tmiddleware.handler import TMiddlewareHandler
define(‘port’, 7777) MIDDLEWARES = [‘plugins.slow_request.SlowRequestMiddleware’, ‘plugins.profile.ProfileMiddleware’] define(“middlewares”, default=MIDDLEWARES, help=”middleware class list”)
- class With(TMiddlewareHandler):
- def get(self):
import time time.sleep(4) return self.finish(‘Hello World!’)
- def run():
application = tornado.web.Application([(‘/’, With)]) http_server = tornado.httpserver.HTTPServer(application, xheaders=True) http_server.listen(options.port, ‘0.0.0.0’) tornado.ioloop.IOLoop.instance().start()
- if __name__ == ‘__main__’:
run()
此处使用了自带的两个 middleware,一个用于查看请求的 profile 信息,一个用于在终端下记录超时的请求
### $ python miminal.py
### $ chrome http://localhost:7777/?__profile__=true
web:

console:

##Plugins
自带了两个:
profile: 查看请求的内部函数耗时信息
slow_request: 记录超时请求
自定义插件参考这两个即可
Metadata
Release files for TMiddleware 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| TMiddleware-0.0.1.tar.gz | 117.1 kB | Without provenance | Details for TMiddleware-0.0.1.tar.gz |
Release files / TMiddleware-0.0.1.tar.gz
| Download URL | TMiddleware-0.0.1.tar.gz |
|---|---|
| Size | 117.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6c9bc06bde21505bba3941804d0e981f382cb552f2e8d284cbbd5ec49e594e0a
|
|
BLAKE2b-256 checksum How to use checksums |
f5ddd327637e35d91389dc8b0aff07d8fc486ba54a9f0c12427ef02675f71302
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for TMiddleware 0.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.