More forms testing

This commit is contained in:
2025-04-01 12:08:56 +02:00
parent f660a33425
commit 6e9df34452
4 changed files with 10 additions and 8 deletions

Binary file not shown.

View File

@@ -4,9 +4,9 @@ from wtforms.validators import DataRequired
class ServiceForm(FlaskForm):
naam = StringField("Service naam:", validators=[DataRequired()])
name = StringField("Service name:", validators=[DataRequired()])
url = URLField("Service URL:", validators=[DataRequired()])
submit = SubmitField("Toevoegen")
submit = SubmitField("Add")
class LoginForm(FlaskForm):

12
run.py
View File

@@ -13,14 +13,16 @@ def index():
return "<h1>This is the default page</h1>"
@app.route("/forms")
@app.route("/forms", methods=["GET", "POST"])
def forms():
service_form = ServiceForm()
form = ServiceForm()
if service_form.validate_on_submit: # type: ignore
session["name"]
if form.validate_on_submit: # type: ignore
session["name"] = form.name.data
session["url"] = form.url.data
return render_template("forms.html", form=service_form)
form = ServiceForm(formdata=None)
return render_template("forms.html", form=form)
# Prevent execution when imported by other script

View File

@@ -11,7 +11,7 @@
<h1>Hallo</h1>
<form method="POST">
{{ form.hidden_tag() }}
{{ form.naam.label }} {{form.naam}}
{{ form.name.label }} {{form.name}}
<br>
{{ form.url.label}} {{form.url}}
<br>