from micro_blog import app
from flask import render_template, flash, redirect, url_for
from micro_blog.forms import LoginForm

@app.route("/")
@app.route("/index")
def index():
    user ={"name":"Sharath"}
    posts=[
        {"author":{"name":'John'},
         "body":"It's a beautiful day"
         },
        {"author": {"name": 'Michael'},
         "body": "What's up dood"
         }
    ]
    return render_template("index.html",user=user,posts=posts)

@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)


