• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
    • Questions
    • Teachers
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

167
Views
path type variable in Flask API endpoint is splitting the variable value

I have an endpoint in my API like below:

from flask import Flask

app = Flask(__name__)

@app.route('/price/<path:url>/')
def Ex(url):
    return {'urlwas':url}

app.run()

The problem is that when I call the API with this http://127.0.0.1:5000/price/https://puresourceindia.in/store/index.php/?route=product/product&product_id=479

it should return this {"urlwas":"https://puresourceindia.in/store/index.php/?route=product/product&product_id=479"}

but it returns {"urlwas":"https://puresourceindia.in/store/index.php"}

I am unable to understand what is happening here, and how to tackle this situation?

about 3 years ago · Santiago Trujillo
1 answers
Answer question

0

You have to URL encode the parameter, the call should become:

http://127.0.0.1:5000/price/https%3A%2F%2Fpuresourceindia.in%2Fstore%2Findex.php%2F%3Froute%3Dproduct%2Fproduct%26product_id%3D479

and the result then becomes the one expected:

{"urlwas":"https://puresourceindia.in/store/index.php/?route=product/product&product_id=479"}

See here how to URL encode your string: https://www.urlencoder.org/

about 3 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 Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error