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__)

def Ex(url):
    return {'urlwas':url}

The problem is that when I call the API with this

it should return this {"urlwas":""}

but it returns {"urlwas":""}

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


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

and the result then becomes the one expected:


See here how to URL encode your string:

Answered By – Matteo Pasini

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published