Browse Source

metadata uploads

main
cellarspoon 3 years ago
parent
commit
b827f6cbe1
No known key found for this signature in database GPG Key ID: 3789458B3D0C410
  1. 2
      .gitignore
  2. 8
      app.py
  3. 6
      templates/index.html

2
.gitignore

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

8
app.py

@ -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

6
templates/index.html

@ -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>

Loading…
Cancel
Save