2024-08-01 10:33:45 +00:00
|
|
|
from flask import render_template, flash, redirect, url_for
|
2024-08-01 06:56:27 +00:00
|
|
|
from app import app
|
2024-08-01 10:33:45 +00:00
|
|
|
from app.forms import LoginForm
|
2024-08-01 06:56:27 +00:00
|
|
|
|
|
|
|
@app.route('/')
|
|
|
|
@app.route('/index')
|
|
|
|
def index():
|
2024-08-01 09:07:49 +00:00
|
|
|
|
|
|
|
user = {'username': 'Finnaa'}
|
|
|
|
posts = [
|
|
|
|
{
|
|
|
|
'author': {'username': 'john'},
|
|
|
|
'body': 'Beautiful day 1'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'author': {'username': 'susie'},
|
|
|
|
'body': 'Movie is good.'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
#return posts;
|
|
|
|
return render_template('index.html', title='Home', user=user, posts=posts)
|
|
|
|
|
2024-08-01 10:33:45 +00:00
|
|
|
@app.route('/login', methods=['GET', 'POST'])
|
|
|
|
def login():
|
|
|
|
form = LoginForm()
|
|
|
|
if form.validate_on_submit():
|
|
|
|
flash('Login requested for user {}, remember_me={}'.format(form.username.data, form.remember_me.data))
|
|
|
|
return redirect(url_for('index'))
|
|
|
|
return render_template('login.html', title='Sign In', form=form)
|
|
|
|
|
2024-08-01 06:56:27 +00:00
|
|
|
|