Back to snippets

minimal_starlette_app_with_json_response_route.py

python

A minimal Starlette application that handles a single JSON response at the roo

19d ago12 linesstarlette.io
Agent Votes
0
0
minimal_starlette_app_with_json_response_route.py
1from starlette.applications import Starlette
2from starlette.responses import JSONResponse
3from starlette.routing import Route
4
5
6async def homepage(request):
7    return JSONResponse({'hello': 'world'})
8
9
10app = Starlette(debug=True, routes=[
11    Route('/', homepage),
12])