-
-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy pathroutes.py
36 lines (26 loc) · 1.11 KB
/
routes.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
"""Routing."""
from flask import current_app as app
from flask import redirect, render_template, url_for
from flask_wtforms_tutorial.forms import ContactForm, SignupForm
@app.route("/")
def home():
"""Landing page."""
return render_template("index.jinja2", template="home-template", title="Flask-WTF tutorial")
@app.route("/contact", methods=["GET", "POST"])
def contact():
"""Standard `contact` form."""
form = ContactForm()
if form.validate_on_submit():
return redirect(url_for("success"))
return render_template("contact.jinja2", form=form, template="form-template", title="Contact Form")
@app.route("/signup", methods=["GET", "POST"])
def signup():
"""User sign-up form for account creation."""
form = SignupForm()
if form.validate_on_submit():
return redirect(url_for("success"))
return render_template("signup.jinja2", form=form, template="form-template", title="Signup Form")
@app.route("/success", methods=["GET", "POST"])
def success():
"""Generic success page upon form submission."""
return render_template("success.jinja2", template="success-template")