metadata uploads

This commit is contained in:
cellarspoon 2021-12-06 11:14:56 +01:00
parent dd60df3f18
commit b827f6cbe1
No known key found for this signature in database
GPG Key ID: 03789458B3D0C410
3 changed files with 9 additions and 7 deletions

2
.gitignore vendored
View File

@ -1,3 +1,3 @@
__pycache__
metadatum
venv
pdfs

8
app.py
View File

@ -18,7 +18,9 @@ CWD = Path().resolve()
class UploadForm(FlaskForm):
pdf = FileField(validators=[FileAllowed(["pdf"], "PDFs only!"), FileRequired()])
metadata = FileField(
validators=[FileAllowed(["db"], "Metadata databases only"), FileRequired()]
)
class CardSidesForm(FlaskForm):
@ -40,9 +42,9 @@ def upload():
card_sides_form = CardSidesForm()
if upload_form.validate_on_submit():
f = upload_form.pdf.data
f = upload_form.metadata.data
filename = secure_filename(f.filename)
f.save(os.path.join(CWD, "pdfs", filename))
f.save(os.path.join(CWD, "metadatum", filename))
return redirect(url_for("home"))
return render_template(
"index.html", upload_form=upload_form, card_sides_form=card_sides_form

View File

@ -7,13 +7,13 @@
</head>
<body>
<form method="POST" action="/upload" enctype="multipart/form-data">
{{ upload_form.csrf_token }} {{ upload_form.pdf }}
{{ upload_form.csrf_token }} {{ upload_form.metadata }}
<input type="submit" value="Go" />
</form>
{% if upload_form.pdf.errors %}
{% if upload_form.metadata.errors %}
<ul class="errors">
{% for error in upload_form.pdf.errors %}
{% for error in upload_form.metadata.errors %}
<li>{{ error }}</li>
{% endfor %}
</ul>