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__ __pycache__
metadatum
venv venv
pdfs

8
app.py
View File

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

View File

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