summaryrefslogtreecommitdiff
path: root/website/app/routes.py
blob: f1497b8281485d8454e41d3dabe393004c9013e2 (plain)
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
from flask import Flask, render_template, flash, redirect, url_for
from forms import RegistrationForm, LoginForm

app = Flask(__name__)
app.config['SECRET_KEY'] = 'foobarblendoitfoobar!'

posts = [{
    'author':
    'Marius',
    'date':
    'Dec. 26th, 2019',
    'content':
    "this is a test where I write a message that isn't too short, it isn't too long, it's just the right size."
}, {
    'author': 'Achille',
    'date': 'Dec. 25th, 2019',
    'content': "this is a second test!"
}, {
    'author': 'Jeanne',
    'date': 'Dec. 24th, 2019',
    'content': "this is a third test!"
}]


@app.route("/")
@app.route("/home")
def home():
    return render_template('home.html', posts=posts)

@app.route("/yes")
def yes():
    return render_template("yes.html")

@app.route("/no")
def no():
    return render_template("no.html")

@app.route("/register", methods=['GET', 'POST'])
def register():
    form = RegistrationForm()
    if form.validate_on_submit():
        flash(f"Alias created for {form.alias.data}.", 'success')
        return redirect(url_for('home'))
    return render_template('register.html', title="Register", form=form)


@app.route("/login")
def login():
    form = LoginForm()
    return render_template('login.html', title="Login", form=form)


if __name__ == '__main__':
    app.run(debug=True)
Copyright 2019--2024 Marius PETER