Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

377
Views
Starlette/FastApi route path components with forward slash

I have defined a route in Starlette/FastApi -

@router.post("/{part}")
def post_method(part):
    return "ok"

@router.post("/{part}/{another_part}")
def another_post_method(part, another_part):
    return "ok"

I have some forward slash in the path components, and I want to make the following request to access post_method

curl -X POST "http://127.0.0.1:5000/api/path%2Fpath" -H "accept: application/json" -d ""

results in the 404 error in the Starlette/Fastapi logs.

INFO: 127.0.0.1:50233 - "POST /api/path/path HTTP/1.1" 404

How to get the correct path components?

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

You can use Starlette built-in path convertor

@app.route("/path/{param:path}", name="path-convertor")
over 4 years ago · Santiago Trujillo Report

0

Response from Marcelo Trylesinski (Kludex) in fastapi gitter:

  1. It is not allowed
  2. Temporary solution: don't use path
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!