Skip to content

Instantly share code, notes, and snippets.

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:
return ''
if __name__ == '__main__':"", port=3000, debug=True)
Invoke-RestMethod -Uri -Method Post -Infile .\report.xml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment