Mounted subroutes require the trailing /
to hit their 'root' subroute, whereas regular Route
s do not.
E.g.
from starlette.applications import Starlette from starlette.requests import Request from starlette.responses import PlainTextResponse from starlette.routing import Mount, Route async def homepage(request): return PlainTextResponse('homepage') async def subroute(request): return PlainTextResponse('subroute') routes = [ Route('/', homepage), Mount('/sub', routes=[Route('/', subroute)]), ] app = Starlette(debug=True, routes=routes)
localhost:8000
and localhost:8000/
both return "hompage", whereas localhost:8000/sub
returns a 307 temp redirect to localhost:8000/sub/
which then returns "subroute".
Small issue and not saying either approach is correct, but I guess I would expect both Mount
and Route
to behave the same here.
Using version 13.1.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4