I am trying to pass a nested dictionary as a parameter to a GET request, which is handled by a Flask worker. The whole setup is Nginx+Gunicorn+Flask. On the client, I am doing the following:
import requests def find_cabin(): party = {'People' : [{'Age': 44, 'Gender': 'F', 'Habits': 'Smoking,Drinking'}, {'Age': 9, 'Gender': 'F'} , {'Age': 4, 'Gender': 'F'}, {'Age': 49, 'Gender': 'M'}], 'Vehicles': [{'Make/Model': 'Honda Civic'}, {'Make/Model': 'Toyota RAV4'}], 'Must Haves':['Deck', 'Fireplace', 'Boat launch', {'Bedrooms': 2}]} uri = 'mysite.com/find_cabin' headers = {'Content-Type': 'application/json', 'Accept': 'text/plain'} res = requests.get(uri, data=json.dumps(party), headers=headers) return res.text
On the server, in my Flask handler, I am doing this:
@app.route('/find_cabin/', methods=['GET']) def find_cabin(): payload = request.data # payload is empty print ('payload for find_cabin: ', payload) #process request
The payload is empty. What am I missing? How should I pass complex nested structures to my Flask app?