Monday, March 28, 2022

[SOLVED] Flask second parameter returns null

Issue

when I try to return the second argument background for my Flask application, I get a null value, but it works fine for original

> curl http://127.0.0.1:5000?original="sdsd" & background="/szzzzzz" 

@app.route('/',methods=['GET'])
def API():
    if request.method == 'GET':
        original = request.args.get('original')
        background = request.args.get('background')
        result =  background
        return jsonify(result)

Solution

Likely your shell is ignoring the part after the & because that character is signaling the shell the run the first part of the command in the background.

Try running your curl command like this:

curl "http://127.0.0.1:5000?original=sdsd&background=/szzzzzz" 

The quotation marks will escape the & character so that the entire string is passed to curl.



Answered By - poundifdef
Answer Checked By - Terry (WPSolving Volunteer)