NanoASGI is a fast, simple and lightweight ASGI micro web-framework for Python. It is distributed as a single file module and has no dependencies other than the Python Standard Library.
Download nanoasgi.py into your project directory. There are no hard dependencies other than the Python standard library. NanoASGI runs with Python versions above 3.7.
from nanoasgi import App
app = App()
@app.on('startup')
async def on_startup():
print('Ready to serve requests')
@app.on('shutdown')
async def on_shutdown():
print('Shutting down')
@app.route('GET', '/api/hello/{name}/')
async def hello_handler(request, name):
return Response(
{'result': f'Hello {name}!'},
status=200,
headers=[('Content-Type', 'application/json')],
)
uvicorn example:app
Code and documentation are available according to the MIT License (see LICENSE).
The Bottle logo however is NOT covered by that license. It is allowed to use the logo as a link to the repo or in direct context with the unmodified library. In all other cases, please ask first.