Starlette catch all routes and http methods
Question:
I want to make my function proxy
accepts ALL paths and all HTTP methods, everything that hits the Starlette app I want to proxy function handles it.
async def proxy(request: Request):
pass
routes = [
Route("/", endpoint=proxy),
]
app = Starlette(routes=routes)
I tried the code above, but no luck.
How to do this?
Answers:
Try using an optional, catch-all path.
routes = [
Route("/{path:path}", endpoint=proxy),
]
It can be empty OR anything else.
I want to make my function proxy
accepts ALL paths and all HTTP methods, everything that hits the Starlette app I want to proxy function handles it.
async def proxy(request: Request):
pass
routes = [
Route("/", endpoint=proxy),
]
app = Starlette(routes=routes)
I tried the code above, but no luck.
How to do this?
Try using an optional, catch-all path.
routes = [
Route("/{path:path}", endpoint=proxy),
]
It can be empty OR anything else.