
from flask import render_template,session,redirect,url_for,current_app
from . import auth
from .form import LoginForm
from ..models import User
@auth.route('/')
def index():
#return 'Welcome!'
return render_template('index.html')
@auth.route('/login',methods=['GET', 'POST'])
def login():
form = LoginForm()
if form.validate_on_submit():
user = User.query.filter_by(username = form.name.data).first()
if user is None:
flash("你输入的用户不存在!")
else:
return redirect(url_for('.index'))
return render_template('login.html')
错误:

原因:
flask app程序要在根目录路径下寻找模板文件!
网友评论