Skip to main content

Router middleware for xweb.

Project description

xweb-router

Router middleware for xweb

Usage

from xweb import App

from xweb_router import Router

app = App()
router = Router()
nested = Router()

app.use(router)


@router.use('/')
async def middleware(ctx, fn):
    """Router Middleware"""
    print('middleware')
    await fn()


@router.post('/')
async def home(ctx):
    ctx.body = "Home"


@router.get('/{name}')
async def hello(ctx):
    """URL parameters"""
    ctx.body = f"Hello {ctx.params.name}"


router.use('/post')(nested)


@nested.get('/index')
async def index(ctx):
    ctx.body = "Nested Index"


if __name__ == '__main__':
    app.listen(8000)

Nested Router


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

xweb_router-0.1.1.tar.gz (2.4 kB view details)

Uploaded Source

Built Distribution

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

xweb_router-0.1.1-py3-none-any.whl (2.5 kB view details)

Uploaded Python 3

File details

Details for the file xweb_router-0.1.1.tar.gz.

File metadata

  • Download URL: xweb_router-0.1.1.tar.gz
  • Upload date:
  • Size: 2.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.6.5

File hashes

Hashes for xweb_router-0.1.1.tar.gz
Algorithm Hash digest
SHA256 726fbebba94b3e50ec1c0a82eebc3961cb95524d01806b2fc17a4d3931bb273e
MD5 2a7a527a9ecad075cf7de96c59aa1acb
BLAKE2b-256 7ce93c448ae4adb3a599a36a116d13405d667edc28a0534eb81e6c7ec6d26534

See more details on using hashes here.

File details

Details for the file xweb_router-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: xweb_router-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 2.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.6.5

File hashes

Hashes for xweb_router-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 103981f1b5df4bb08d2f731eccf66b973f5e6df160c86c2bd804c1f5380aa969
MD5 d13dbdda20f98d78d22503f7a5007991
BLAKE2b-256 9cd8e8fb9446b4f90266b01d8e9a57c1be43fec9cf2514aecdbd124c65fc97f1

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