Ratio
raw JSON → 0.4.0 verified Fri May 01 auth: no python
Ratio is a Python web framework designed for productivity, inspired by Flask and FastAPI. It provides a minimalist, expressive routing system and encourages rapid development. The current version is 0.4.0, targeting Python >=3.11, with a monthly release cycle.
pip install ratio Common errors
error ModuleNotFoundError: No module named 'ratio.core' ↓
cause Import path changed in version 0.3.0.
fix
Change import to
from ratio import Ratio. error TypeError: route() missing 1 required positional argument: 'func' ↓
cause Using @app.route without parentheses or arguments incorrectly.
fix
Use @app.route('/path') not @app.route('/path')() or @app.route.
Warnings
gotcha Version 0.3.0 changed the import path from `ratio.core` to `ratio`. Old code using `from ratio.core import Ratio` will break. ↓
fix Use `from ratio import Ratio`.
gotcha Route handlers must accept at least a `request` parameter. Omitting it causes a TypeError at runtime. ↓
fix Define handlers with `def handler(request):` even if request is unused.
Imports
- Ratio wrong
from ratio import Applicationcorrectfrom ratio import Ratio
Quickstart
from ratio import Ratio
app = Ratio()
@app.route('/')
def home(request):
return 'Hello, World!'
if __name__ == '__main__':
app.run()