示例#1
0
文件: views.py 项目: sluo1/flaskapp
def login():
    if request.method=='GET':
        return render_template("login.html")
    elif request.method=='POST':
        # print "ccc"
        # print request.form['username']
        # print get_md5(request.form['password'])
        # suser=User.query.filter_by(username=request.form['username'],password=get_md5(request.form['password'])).first()
        # print 'aaa'
        form_dict=dict(request.form)
        s_user = User.query.filter_by(username=form_dict['name'][0],\
                password=get_md5(form_dict['password'][0])).first()
        if s_user:
            g.user=s_user
            print 'bbb'
            flash('login success','success')
            return redirect(url_for('user'))
        else:
            flash('user or password wrong,please try again','fail')
            return redirect(url_for('login'))
    else:
        abort(404)
示例#2
0
文件: models.py 项目: sluo1/flaskapp
 def __init__(self,username,email,password):
     self.username=username
     self.email=email
     self.password=get_md5(password)