Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tombulled/routing
Routing in Python made easy
https://github.com/tombulled/routing
route router routing
Last synced: 23 days ago
JSON representation
Routing in Python made easy
- Host: GitHub
- URL: https://github.com/tombulled/routing
- Owner: tombulled
- License: mit
- Created: 2021-05-24T12:59:37.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-06-07T20:37:51.000Z (over 2 years ago)
- Last Synced: 2023-03-05T18:53:58.118Z (almost 2 years ago)
- Topics: route, router, routing
- Language: Python
- Homepage:
- Size: 24.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# routing
Routing for Python## Example: Basic
```python
import routingrouter = routing.Router()
@router.route('hello')
def hello():
print('Hello!')
``````python
>>> router('hello')
Hello!
```## Example: Passing Arguments
```python
import routingrouter = routing.Router()
@router.route('say')
def say(message):
print(message)
``````python
>>> router('say', 'Hello, World')
Hello, World
```## Example: Path Parameters
```python
import routingrouter = routing.Router()
@router.route('turn {direction}')
def turn(direction):
print(f'Turning: {direction}')
``````python
>>> router('turn left')
Turning: left
```## Example: Middleware
```python
import routingrouter = routing.Router()
@router.middleware
def only_eat_pizza(call_next, request):
request.args = routing.Arguments('pizza')return call_next(request)
@router.route('eat {food}')
def eat(food):
print(f'Eating: {food}')
``````python
>>> router('eat vegetables')
Eating: pizza
```