python:flask-api
This is an old revision of the document!
Table of Contents
Output result from API
The BASH below is not specific to Flask, but the MySQL probably is.
Debugging API calls
Send to this URL to see just what you have actually sent to help any debugging.
Send to POST test data
curl -i -X POST \ -H 'Content-Type: application/json' \ -d "{\"auth_token\":\"${AUTH_TOKEN}\", \"user_id\":\"${EMAIL}\", \"file_ref\":\"File.odt\", \"uuid\":\"${UUID}\"}" \ http://192.168.11.7:5000/api
Output
Get output from MySQL in the form of a Tuple and return it without any html encoding, ie. just as a json object.
mycursor = mydb.cursor() mycursor.execute(sql) user_id = mycursor.fetchone() # returns a tuple lookup_userid = {"userid":user_id[0]} response = make_response(jsonify({"id": str(lookup_userid) }), 200,) response.headers["Content-Type"] = "application/json" return response
python/flask-api.1754557751.txt.gz · Last modified: by andrew