User Tools

Site Tools


python:flask-api

Output result from API

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
 
# Note:- send to this URL to see just what you have actually sent to help any debugging.
# https://httpbin.org/anything

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.txt · Last modified: by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki