guri guri - 16 days ago 10
HTTP Question

How to configure Flask to consider URL as one argument passed through CURL command

import Flask
app.route('/urlinfo/1/<URL>', methods=['GET'])
def search(URL):
print URL


I am making curl command to to test it

curl http://127.0.0.1:5000/urlinfo/1/http://www.dsdsd.com


Since URL include '//' Flask consider it as a second argument and throw an error.

1.How to pass whole URL as an one argument in

curl http://127.0.0.1:5000/urlinfo/1/http://www.dsdsd.com/path command?


2.How to check that Enter URL is valid?

Answer

Change your decorator to this:

@app.route('/urlinfo/1/<path:URL>', methods=['GET'])

By adding path to the URL arguments, slashes should be accepted.

Comments