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
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.
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.

Minimal Ratio application with a single route.

from ratio import Ratio

app = Ratio()

@app.route('/')
def home(request):
    return 'Hello, World!'

if __name__ == '__main__':
    app.run()