Skip to main content
# biro

bidirectional URI routing

```python
from biro import get, path_for, match

@get('/article')
def list_article():
pass

@get('/article/<article_id>')
def show_article():
pass

path_for(show_article, article_id=618) # /article/618
path_for(list_article, limit=10) # /article?limit=10

match('GET', "/article/309") # (article, {"article_id": "309"})
match('POST', "/article/309") # (None, None)
```

## the Router class

```python
from biro import Router

router = Router()
router.append('DETELE', '/article/<article_id>', handler)

router.match('PATCH', '/path')
router.path_for(handler, q=val)
```

## wsgi example

```python
from biro import get, match

@get('/')
def home():
return 'home'

@get('/hello/<name>')
def hello(name):
return 'hello %s' % name

def application(environ, start_response):
handler, params = match(environ['REQUEST_METHOD'].upper(),
environ['PATH_INFO'])
if handler:
status = '200 OK'
response = handler(**params)
else:
status = '404 Not Found'
response = 'page not found'
start_response(status, [('Content-Type', 'text/html; charset=utf-8')])
return [response.encode('utf-8')]
```

save it as example.py, then it can be lunched using gunicorn like this:

```
$ gunicorn example:application
```

Download files

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

Source Distribution

biro-0.0.4.tar.gz (3.0 kB view details)

Uploaded Source

File details

Details for the file biro-0.0.4.tar.gz.

File metadata

  • Download URL: biro-0.0.4.tar.gz
  • Upload date:
  • Size: 3.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for biro-0.0.4.tar.gz
Algorithm Hash digest
SHA256 91f0bf51d8ab654cdb0fbbca0a0a0e5d82e748c755927bf938385fb3f5dfc878
MD5 753c0ac29ffa60cb8ab9408a3bda691c
BLAKE2b-256 340507f71b2b0f622ca310f3528d17842db791d4d5d8fcbd0243645d6dbf4531

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.0.4 This release

1 file

0.0.3

1 file

0.0.2

1 file

0.0.1

1 file

Supported by

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