metadata uploads
This commit is contained in:
parent
dd60df3f18
commit
b827f6cbe1
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,3 +1,3 @@
|
||||
__pycache__
|
||||
metadatum
|
||||
venv
|
||||
pdfs
|
||||
|
8
app.py
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
|
||||
|
@ -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…
Reference in New Issue
Block a user