Skip to main content
# biro

bidirectional URI routing

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

def article():
pass

get('/article/<article_id>', article)

path_for(article, article_id=618) # /article/618

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

decorators

```python
from biro import delete

@delete('/article/<article_id>')
def article():
pass
```

RESTful shortcut

```python
from biro import resource

resource('/article', article_module_or_class)

resources(m_or_c, m_or_c2, prefix='/v2')
```

the resource decorator

```python
@resource('/v1/article')
class Article:
def show(article_id):
pass

def create():
pass

@method('patch')
def like(article_id):
pass
```

default rules

```python
('GET', '%(path)s', 'query'),
('POST', '%(path)s', 'create'),
('GET', '%(path)s/<%(id)s>', 'show'),
('PUT', '%(path)s/<%(id)s>', 'replace'),
('PATCH', '%(path)s/<%(id)s>', 'modify'),
('DELETE', '%(path)s/<%(id)s>', 'destroy'),
('GET', '%(path)s/new', 'new'),
('GET', '%(path)s/<%(id)s>/edit', 'edit'),
```

## 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
```

Metadata

Release files for biro 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for biro 0.0.2
File Size Uploaded
biro-0.0.2.tar.gz 4.0 kB Details

Release files / biro-0.0.2.tar.gz

Download URL biro-0.0.2.tar.gz
Size 4.0 kB
Tags Source
SHA-256 checksum
How to use checksums
ff852ab8e0a0f933400a8d23ea953b580e2f71a0a4496c22eb9063c527999541
BLAKE2b-256 checksum
How to use checksums
21b976853c9c66fe10b15892171766de71156b9c8391e7fa96cf2d4ad2298c31
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

0.0.4

1 release file

0.0.3

1 release file

This release

0.0.2 This release

1 release file

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page