How do I handle multiple slashes in the URL path leading, mid-path or trailing, similar to non strict slashes in Flask.
See original GitHub issueFirst check
- I added a very descriptive title to this issue.
- I used the GitHub search to find a similar issue and didn’t find it.
- I searched the FastAPI documentation, with the integrated search.
- I already searched in Google “How to X in FastAPI” and didn’t find any information.
- I already read and followed all the tutorial in the docs and didn’t find an answer.
- I already checked if it is not related to FastAPI but to Pydantic.
- I already checked if it is not related to FastAPI but to Swagger UI.
- I already checked if it is not related to FastAPI but to ReDoc.
- After submitting this, I commit to one of:
- Read open issues with questions until I find 2 issues where I can help someone and add a comment to help there.
- I already hit the “watch” button in this repository to receive notifications and I commit to help at least 2 people that ask questions in the future.
- Implement a Pull Request for a confirmed bug.
Example
Here’s a self-contained, minimal, reproducible, example with my use case:
from fastapi import FastAPI
app = FastAPI()
@app.get("/hello/x")
def read_root():
return {"Hello": "World"}
Description
curl http://localhost:8000/hello/x --> is OK
curl http://localhost:8000///hello///x --> throws 404
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Trailing slash triggers 404 in Flask path rule - python
Your /users route is missing a trailing slash, which Werkzeug interprets as an explicit rule to not match a trailing slash. Either add...
Read more >10.3. Routing — Fundamentals of Web Programming
It's similar to a folder in a file system. If you access the URL without a trailing slash, Flask redirects you to the...
Read more >Trailing slash rule. Is this behaviour flask specific or ...
I just made a no brainer rule to always add trailing slash to every route... is this okay or this should be used...
Read more >Trailing slash on URLs / Navigation issue
Solved: Two questions here related to URL structure. When we migrated our website to Hubspot, a decision was made to add trailing slashes...
Read more >4. Routing — Flask API - GitHub Pages
In that sense, it is similar to a folder on a filesystem. Accessing it without a trailing slash will cause Flask to redirect...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@NightMachinary
Thanks for the help and discussion here everyone!
And thanks for coming back to close the issue @mehmetg ☕