Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 23247

How to receive file send from flask with curl?

$
0
0

Here the server side code with python & flask:

from flask import Flask, request, send_fileimport ioimport zipfileimport bitstringapp = Flask(__name__)@app.route('/s/',  methods=['POST'])def return_files_tut():    try:        f = io.BytesIO()        f.write("abcd".encode())        return send_file(f, attachment_filename='a.ret.zip')    except Exception as e:        return str(e)if __name__ == '__main__':    app.run(debug=True)

Bellowing is curl command:

λ curl -X POST  http://localhost:5000/s/ -o ret.tmp  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current                                 Dload  Upload   Total   Spent    Left  Speed  0     4    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0curl: (18) transfer closed with 4 bytes remaining to read

How should I use curl to receive the file?


Viewing all articles
Browse latest Browse all 23247

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>