-
Can we define the from starlette.applications import Starlette
from starlette.routing import Route
async def homepage(request):
return # exit app
routes = [
Route('/', homepage, methods=['GET', 'POST']),
]
app = Starlette(routes=routes) This allows use cases like this "Experimental Features" without hassle. Changing this is unlikely to have any impact as servers generally already handle this:
And is even a bit cleaner than the current behavior:
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
You need to use The idea is that the endpoint returns an ASGI app. |
Beta Was this translation helpful? Give feedback.
-
Thanks for the answer. In the general case of course we use By defining async def app(scope: Scope, receive: Receive, send: Send) -> None:
response = await f(request)
+ if response is None:
+ return
await response(scope, receive, send) |
Beta Was this translation helpful? Give feedback.
You need to use
Response
.The idea is that the endpoint returns an ASGI app.