Skip to main content

A microframework

Project description

A microframework for Python 3, based on werkzeug.

https://img.shields.io/pypi/l/rouver.svg https://img.shields.io/github/release/srittau/rouver/all.svg https://img.shields.io/pypi/v/rouver.svg https://travis-ci.org/srittau/rouver.svg?branch=master

Routing

>>> from rouver.router import Router
>>> from rouver.response import respond_with_html, respond_with_json
>>> def get_index(request, path, start_response):
...     return respond_with_html(start_response, "<div>Foo</div>")
>>> def get_count(request, path, start_response):
...     return respond_with_json(start_response, {"count": 42})
>>> router = Router()
>>> router.add_routes([
...     ("", "GET", get_index),
...     ("count", "GET", get_count),
... ])

Routes with placeholders:

>>> def get_addition(request, path, start_response):
...     num1, num2 = path
...     return response_with_json(start_response, {"result": num1 + num2})
>>> def numeric_arg(request, path, value):
...     return int(value)
>>> router.add_template_handler("numeric", numeric_arg)
>>> router.add_routes([
...     ("add/{numeric}/{numeric}", "GET", get_addition),
... ])

Argument Handling

>>> from rouver.args import Multiplicity, parse_args
>>> from rouver.response import respond_with_json
>>> def get_count_with_args(request, path, start_response):
...     args = parse_args(request.environ, [
...         ("count", int, Multiplicity.REQUIRED),
...     ])
...     return respond_with_json({"count": args["count"]})

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

rouver-0.4.1-py3-none-any.whl (21.0 kB view details)

Uploaded Python 3

File details

Details for the file rouver-0.4.1-py3-none-any.whl.

File metadata

File hashes

Hashes for rouver-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 af66e62c265ab2ccfc0de5588c9db8409c30defb1c5ec2cd1d6d2f47edc4b3e8
MD5 e9c2ff14b53853d7fcb23e77c81e908e
BLAKE2b-256 1c313c279be9c1c526dd1d8c8c582e2ef8a5fa2d0183250cc76d1b9a738be58e

See more details on using hashes here.

Supported by

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