microblog/app/views.py

34 lines
967 B
Python
Raw Normal View History

2012-12-16 08:28:52 +00:00
from flask import render_template, flash, redirect
2012-12-16 08:24:07 +00:00
from app import app
2012-12-16 08:28:52 +00:00
from forms import LoginForm
2012-12-16 08:24:07 +00:00
@app.route('/')
@app.route('/index')
def index():
2012-12-16 08:26:19 +00:00
user = { 'nickname': 'Miguel' }
posts = [
{
'author': { 'nickname': 'John' },
'body': 'Beautiful day in Portland!'
},
{
'author': { 'nickname': 'Susan' },
'body': 'The Avengers movie was so cool!'
}
]
2012-12-16 08:28:52 +00:00
return render_template('index.html',
2012-12-16 08:26:19 +00:00
title = 'Home',
user = user,
posts = posts)
2012-12-16 08:28:52 +00:00
@app.route('/login', methods = ['GET', 'POST'])
def login():
form = LoginForm()
if form.validate_on_submit():
flash('Login requested for OpenID="' + form.openid.data + '", remember_me=' + str(form.remember_me.data))
return redirect('/index')
return render_template('login.html',
title = 'Sign In',
form = form,
providers = app.config['OPENID_PROVIDERS'])