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.3.tar.gz (3.3 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.3-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: tornado-request-mapping-0.0.3.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.24.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.3.tar.gz
Algorithm Hash digest
SHA256 a7b08d5d494f53c924d23a4e49d8e5891cd8cdc6268ebb94195dd29b552e25fa
MD5 60fd71056f6067554c48d364559cd670
BLAKE2b-256 59990c352c72473af6a13308aafb8dd3c1ff67a57377791e5d8565eb4d1afdad

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tornado_request_mapping-0.0.3-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.24.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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 749beff71044c91d098bf3110ba106e182352809ca1e3058cf77a92d16657f99
MD5 ab44fd7972af930cb5c1d9b5fc2951a1
BLAKE2b-256 97c3caca9211597ea4914204afe994649d1f379485f5428c8b43bcfc768186b8

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