mirror of
https://github.com/StefBuwalda/WebTech.git
synced 2025-10-30 19:29:58 +00:00
More forms testing
This commit is contained in:
Binary file not shown.
4
forms.py
4
forms.py
@@ -4,9 +4,9 @@ from wtforms.validators import DataRequired
|
|||||||
|
|
||||||
|
|
||||||
class ServiceForm(FlaskForm):
|
class ServiceForm(FlaskForm):
|
||||||
naam = StringField("Service naam:", validators=[DataRequired()])
|
name = StringField("Service name:", validators=[DataRequired()])
|
||||||
url = URLField("Service URL:", validators=[DataRequired()])
|
url = URLField("Service URL:", validators=[DataRequired()])
|
||||||
submit = SubmitField("Toevoegen")
|
submit = SubmitField("Add")
|
||||||
|
|
||||||
|
|
||||||
class LoginForm(FlaskForm):
|
class LoginForm(FlaskForm):
|
||||||
|
|||||||
12
run.py
12
run.py
@@ -13,14 +13,16 @@ def index():
|
|||||||
return "<h1>This is the default page</h1>"
|
return "<h1>This is the default page</h1>"
|
||||||
|
|
||||||
|
|
||||||
@app.route("/forms")
|
@app.route("/forms", methods=["GET", "POST"])
|
||||||
def forms():
|
def forms():
|
||||||
service_form = ServiceForm()
|
form = ServiceForm()
|
||||||
|
|
||||||
if service_form.validate_on_submit: # type: ignore
|
if form.validate_on_submit: # type: ignore
|
||||||
session["name"]
|
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
|
# Prevent execution when imported by other script
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
<h1>Hallo</h1>
|
<h1>Hallo</h1>
|
||||||
<form method="POST">
|
<form method="POST">
|
||||||
{{ form.hidden_tag() }}
|
{{ form.hidden_tag() }}
|
||||||
{{ form.naam.label }} {{form.naam}}
|
{{ form.name.label }} {{form.name}}
|
||||||
<br>
|
<br>
|
||||||
{{ form.url.label}} {{form.url}}
|
{{ form.url.label}} {{form.url}}
|
||||||
<br>
|
<br>
|
||||||
|
|||||||
Reference in New Issue
Block a user