flask - WeichselRiver/manual GitHub Wiki
python:
for f in request.files.getlist("files[]"):
if filename_allowed(f.filename):
txt = f.read().decode("utf-8")
report += f"{f.filename} : {txt} \n"
else:
report += f"{f.filename} nicht gültig. \n"
# with open("Output.txt", "w") as text_file:
# text_file.write(report)
report = "<h1> master </h1>"
html:
<form enctype='multipart/form-data' method='POST' action='/upload_files'>
<input type='file' name='files[]' accept=".txt,.TXT" multiple/>
<button type='submit'>Submit</button>
</form>
download without saving:
return Response(report,mimetype="text/plain", headers={"Content-Disposition":"attachment;filename=test.txt"})