mirror of
https://github.com/FAUSheppy/ths-blowerdoor-raven
synced 2025-12-07 15:31:36 +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 flask
|
||||||
import argparse
|
import argparse
|
||||||
import glob
|
import glob
|
||||||
@@ -5,13 +7,24 @@ import os
|
|||||||
from data import BlowerdoorData
|
from data import BlowerdoorData
|
||||||
import datetime
|
import datetime
|
||||||
import os.path
|
import os.path
|
||||||
|
import werkzeug.utils
|
||||||
|
|
||||||
import eg_geiss_bauherren as parserBackend
|
import eg_geiss_bauherren as parserBackend
|
||||||
|
|
||||||
app = flask.Flask("THS-Raven")
|
app = flask.Flask("THS-Raven")
|
||||||
|
|
||||||
@app.route("/")
|
@app.route("/", methods=["GET", "POST"])
|
||||||
def root():
|
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 = []
|
allFiles = []
|
||||||
loaded = None
|
loaded = None
|
||||||
for filename in glob.glob("static/files/*.pdf"):
|
for filename in glob.glob("static/files/*.pdf"):
|
||||||
@@ -55,4 +68,4 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
app.run(host=args.interface, port=args.port)
|
app.run(host=args.interface, port=args.port)
|
||||||
|
|||||||
6
static/site.css
Normal file
6
static/site.css
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
.form-border{
|
||||||
|
padding: 10px;
|
||||||
|
border-width: 2px;
|
||||||
|
border-style: solid;
|
||||||
|
border-color: #8c8080;
|
||||||
|
}
|
||||||
@@ -7,6 +7,11 @@
|
|||||||
<body>
|
<body>
|
||||||
{% include 'navbar.html' %}
|
{% include 'navbar.html' %}
|
||||||
<div style="font-size: 16px; font-weight: 300;" class="container mt-5 mb-3" role="main">
|
<div style="font-size: 16px; font-weight: 300;" class="container mt-5 mb-3" role="main">
|
||||||
|
<form class="my-3 form-border" action="/" method="POST" enctype="multipart/form-data">
|
||||||
|
<input type="file" name="file" />
|
||||||
|
<input type="submit" value="Upload"/>
|
||||||
|
</form>
|
||||||
|
<hr class="my-2">
|
||||||
<table id="tableMain" class="table table-striped table-bordered table-sm"
|
<table id="tableMain" class="table table-striped table-bordered table-sm"
|
||||||
cellspacing="0">
|
cellspacing="0">
|
||||||
<thead>
|
<thead>
|
||||||
|
|||||||
Reference in New Issue
Block a user