Skip to main content

make routing similar to flask blueprint

Project description

  • Just like flask blueprint, Handler match to url prefix and the url endpoint map to handler instance method decorated by route decorator.

INSTALL

pip install tor-router (recommended pypi: "https://pypi.python.org/pypi")

EXAMPLE

from tornado import gen
from tornado.httpserver import HTTPServer
from tornado.ioloop import IOLoop
from web import TrfRequestHandler, route, TrfApplication


class TrfHandler(TrfRequestHandler):
    def get(self, *args, **kwargs):
        self.write("get ok")
        self.finish()

    @gen.coroutine
    def post(self, *args, **kwargs):
        self.write("post ok")
        self.finish()

    @route("/hello")
    def say_hello(self, *args, **kwargs):
        self.write("hello")
        self.finish()

    @route("/hi")
    @gen.coroutine
    def say_hi(self, *args, **kwargs):
        self.write("hi")
        self.finish()

    @route("/fine", allow_method=["get", "post", "put"])
    @gen.coroutine
    def say_fine(self, *args, **kwargs):
        self.write("fine")
        self.finish()


if __name__ == '__main__':
    app = TrfApplication([(r"/api", TrfHandler)])
    server = HTTPServer(app)
    print 8988
    server.listen(8988)
    IOLoop.current().start()

Requirement

  • Cpython 2.7.12

  • tornado 4.2.1

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

tor_router-0.0.3.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

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

tor_router-0.0.3-py2-none-any.whl (8.2 kB view details)

Uploaded Python 2

File details

Details for the file tor_router-0.0.3.tar.gz.

File metadata

  • Download URL: tor_router-0.0.3.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/20.7.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/2.7.12

File hashes

Hashes for tor_router-0.0.3.tar.gz
Algorithm Hash digest
SHA256 7a5d96d111e132be77519ca61e6517ebc767cccde1e1937c4fe3c4df169f8af0
MD5 926834ef5995c68d751dcb40c46f21ba
BLAKE2b-256 d9e83629ad4b66fcc26b8ae7bd5ce3a68d6d08c6b9ad2c2356d65bedcd7d36e7

See more details on using hashes here.

File details

Details for the file tor_router-0.0.3-py2-none-any.whl.

File metadata

  • Download URL: tor_router-0.0.3-py2-none-any.whl
  • Upload date:
  • Size: 8.2 kB
  • Tags: Python 2
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/20.7.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/2.7.12

File hashes

Hashes for tor_router-0.0.3-py2-none-any.whl
Algorithm Hash digest
SHA256 b7ed7fa51e9801d2652845f8fc0f37c2cf5972a87321f4c09065ec1b33b037c4
MD5 f7b7eed9c2597cd5c74a687710cc0700
BLAKE2b-256 e4f31632ee51ae22d5d3bb59ffe4a892c6bef9b3dbf1a92f681e55253aa4b7b0

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