python - Flask - Post a file with accompying JSON -
is possible post file flask app has both file , json data accompanying it?
in initial development, doing via 2 api endpoints, , seems clunky. i'd able accomplish using 1 post, instead of two.
is possible?
yes, can post file json data accompanying it. example:
import requests open(path_to_file, 'rb') my_file: files = {'file': my_file} payload = {'data1': 'foo', 'data2': 'bar'} r = requests.post(data=payload, files=files)
there lot of useful information regarding flask , requests (a nice http lib) here:
Comments
Post a Comment