Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
powershell to flask http file upload
from flask import Flask, request
from werkzeug.utils import secure_filename
app = Flask(__name__)
@app.route('/<filename>', methods = ['GET', 'POST'])
def upload_file(filename):
if request.method == 'POST':
data = request.get_data()
filename = secure_filename(filename)
print(filename, len(data))
with open(filename, 'wb') as f:
f.write(data)
return ''
if __name__ == '__main__':
app.run(host="0.0.0.0", port=3000, debug=True)
Invoke-RestMethod -Uri http://127.0.0.1:3000/report.xml -Method Post -Infile .\report.xml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.