cellarspoon
3 years ago
No known key found for this signature in database
GPG Key ID: 3789458B3D0C410
3 changed files with
9 additions and
7 deletions
-
.gitignore
-
app.py
-
templates/index.html
|
|
@ -1,3 +1,3 @@ |
|
|
|
__pycache__ |
|
|
|
metadatum |
|
|
|
venv |
|
|
|
pdfs |
|
|
|
|
|
@ -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 |
|
|
|
|
|
@ -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> |
|
|
|