简体   繁体   中英

Getting URL as a parameter in Flask - but Flask stripping out the params from the URL

I am passing in a URL as a parameter

GET http://127.0.0.1:5000/?url=https://url.com/?param1=123&param2=456

When I grab the URL parameter with request.args.get('url') the value returned is https://url.com/?param1=123 so its stripping off the second parameter in the URL

How can I get all parameters?

You should encode your url, like this

http://127.0.0.1:5000/?url=https%3A%2F%2Furl.com%2F%3Fparam1%3D123%26param2%3D456

use python3

from urllib.parse import urlencode

get_url = '?'.join(['http://127.0.0.1:5000/', urlencode({'url': 'https://url.com/?param1=123&param2=456'})])

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM