one form to rule them all
This commit is contained in:
parent
b827f6cbe1
commit
a98fe6f5d1
23
app.py
23
app.py
@ -21,46 +21,33 @@ class UploadForm(FlaskForm):
|
|||||||
metadata = FileField(
|
metadata = FileField(
|
||||||
validators=[FileAllowed(["db"], "Metadata databases only"), FileRequired()]
|
validators=[FileAllowed(["db"], "Metadata databases only"), FileRequired()]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class CardSidesForm(FlaskForm):
|
|
||||||
title = RadioField("title", choices=[("side a", "side a"), ("side b", "side b")])
|
title = RadioField("title", choices=[("side a", "side a"), ("side b", "side b")])
|
||||||
|
|
||||||
|
|
||||||
@app.route("/")
|
@app.route("/")
|
||||||
def home():
|
def home():
|
||||||
upload_form = UploadForm()
|
upload_form = UploadForm()
|
||||||
card_sides_form = CardSidesForm()
|
return render_template("index.html", upload_form=upload_form)
|
||||||
return render_template(
|
|
||||||
"index.html", upload_form=upload_form, card_sides_form=card_sides_form
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@app.route("/upload", methods=["POST"])
|
@app.route("/upload", methods=["POST"])
|
||||||
def upload():
|
def upload():
|
||||||
upload_form = UploadForm()
|
upload_form = UploadForm()
|
||||||
card_sides_form = CardSidesForm()
|
|
||||||
|
|
||||||
if upload_form.validate_on_submit():
|
if upload_form.validate_on_submit():
|
||||||
f = upload_form.metadata.data
|
f = upload_form.metadata.data
|
||||||
filename = secure_filename(f.filename)
|
filename = secure_filename(f.filename)
|
||||||
f.save(os.path.join(CWD, "metadatum", 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)
|
||||||
"index.html", upload_form=upload_form, card_sides_form=card_sides_form
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@app.route("/generate", methods=["POST"])
|
@app.route("/generate", methods=["POST"])
|
||||||
def generate():
|
def generate():
|
||||||
upload_form = UploadForm()
|
upload_form = UploadForm()
|
||||||
card_sides_form = CardSidesForm()
|
if upload_form.validate_on_submit():
|
||||||
|
print(upload_form.title.data)
|
||||||
if card_sides_form.validate_on_submit():
|
|
||||||
print(card_sides_form.title.data)
|
|
||||||
else:
|
else:
|
||||||
print("didnt work")
|
print("didnt work")
|
||||||
|
|
||||||
return render_template(
|
return render_template("index.html", upload_form=upload_form)
|
||||||
"index.html", upload_form=upload_form, card_sides_form=card_sides_form
|
|
||||||
)
|
|
||||||
|
@ -7,7 +7,11 @@
|
|||||||
</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.metadata }}
|
{{ upload_form.csrf_token }}
|
||||||
|
|
||||||
|
{{ upload_form.metadata }}
|
||||||
|
|
||||||
|
{{ upload_form.title }}
|
||||||
<input type="submit" value="Go" />
|
<input type="submit" value="Go" />
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
@ -19,9 +23,6 @@
|
|||||||
</ul>
|
</ul>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<form method="POST" action="/generate" enctype="multipart/form-data">
|
|
||||||
{{ card_sides_form.csrf_token }} {{ card_sides_form.title }}
|
|
||||||
<input type="submit" value="Go" />
|
|
||||||
</form>
|
</form>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
Loading…
Reference in New Issue
Block a user