mirror of
https://github.com/FAUSheppy/ths-blowerdoor-raven
synced 2025-12-09 08:18:32 +01:00
add upload button
This commit is contained in:
17
server.py
Normal file → Executable file
17
server.py
Normal file → Executable file
@@ -1,3 +1,5 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
import flask
|
||||
import argparse
|
||||
import glob
|
||||
@@ -5,13 +7,24 @@ import os
|
||||
from data import BlowerdoorData
|
||||
import datetime
|
||||
import os.path
|
||||
import werkzeug.utils
|
||||
|
||||
import eg_geiss_bauherren as parserBackend
|
||||
|
||||
app = flask.Flask("THS-Raven")
|
||||
|
||||
@app.route("/")
|
||||
@app.route("/", methods=["GET", "POST"])
|
||||
def root():
|
||||
if flask.request.method == 'POST':
|
||||
fileObj = flask.request.files['file']
|
||||
fname = werkzeug.utils.secure_filename(fileObj.filename)
|
||||
fullpath = os.path.join('static/files/', fname)
|
||||
if not fname.endswith(".pdf"):
|
||||
return (405, "Datei ist kein PDF")
|
||||
else:
|
||||
fileObj.save(fullpath)
|
||||
return flask.redirect("/")
|
||||
|
||||
allFiles = []
|
||||
loaded = None
|
||||
for filename in glob.glob("static/files/*.pdf"):
|
||||
@@ -55,4 +68,4 @@ if __name__ == "__main__":
|
||||
|
||||
|
||||
args = parser.parse_args()
|
||||
app.run(host=args.interface, port=args.port)
|
||||
app.run(host=args.interface, port=args.port)
|
||||
|
||||
Reference in New Issue
Block a user