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)