Skip to main content

spring-like request_mapping for tornado.

Project description

install

pip install -U git+https://github.com/sazima/tornado_request_mapping

A simple example

import tornado.ioloop
from tornado.websocket import WebSocketHandler
import tornado.web
from tornado_request_mapping import request_mapping, Route


@request_mapping("/test")
class MainHandler(tornado.web.RequestHandler):
    @request_mapping('/get_by_id', method='get')
    async def test(self):
        self.write("Hello, world. get")

    @request_mapping('/update_by_id', method='post')
    async def test1(self):
        self.write("Hello, world. post")


@request_mapping('/t')
class MyHandler(tornado.web.RequestHandler):
    @request_mapping('/get_by_id', method='put')
    async def test(self):
        self.write("Hello, world. put")


@request_mapping("/ws")
class Wshandler(WebSocketHandler):
    def open(self, *args: str, **kwargs: str):
        print('open')

    def close(self, code: int = None, reason: str = None) -> None:
        print('close')

    def check_origin(self, origin: str) -> bool:
        return True


if __name__ == "__main__":
    app = tornado.web.Application()

    route = Route(app)
    route.register(MainHandler)
    route.register(MyHandler)
    route.register(Wshandler)

    app.listen(8888)
    tornado.ioloop.IOLoop.current().start()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tornado-request-mapping-0.0.4.tar.gz (3.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tornado_request_mapping-0.0.4-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

Details for the file tornado-request-mapping-0.0.4.tar.gz.

File metadata

  • Download URL: tornado-request-mapping-0.0.4.tar.gz
  • Upload date:
  • Size: 3.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.26.0 setuptools/49.6.0 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.6.12

File hashes

Hashes for tornado-request-mapping-0.0.4.tar.gz
Algorithm Hash digest
SHA256 174f149e95af4e15b2188bb9198f5efe9ab885fc7b97621e86b590e1cc4153c2
MD5 faf4a7832afb78d66d03b5384f28c5d7
BLAKE2b-256 31f46416af909cc06de56737f52561152e1a22a8d90610fd6ae66134149b145a

See more details on using hashes here.

File details

Details for the file tornado_request_mapping-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: tornado_request_mapping-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 3.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.26.0 setuptools/49.6.0 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.6.12

File hashes

Hashes for tornado_request_mapping-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 dab458f2d4e739962875da8c2b0071b5f0681c3b3b2d0e9c1d1de0543ca8c415
MD5 853dbccf171cd8caf848e49768cc3264
BLAKE2b-256 8dae79fa98201da3fd1b58f1a16027b78c5dc80eee2f97af7c842648b2614f45

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page