Created
November 14, 2019 07:07
-
-
Save minhoryang/55ca47a5d27cc122a7eb4a54d319dcfb to your computer and use it in GitHub Desktop.
powershell to flask http file upload
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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