Skip to content

Instantly share code, notes, and snippets.

@minhoryang
Created November 14, 2019 07:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save minhoryang/55ca47a5d27cc122a7eb4a54d319dcfb to your computer and use it in GitHub Desktop.
Save minhoryang/55ca47a5d27cc122a7eb4a54d319dcfb to your computer and use it in GitHub Desktop.
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