def main(): user = None if 'uid' in session: uid = session['uid'] user_model = UserModel(app.config['MYSQL_AGENT']) user = user_model.query_user('userid', uid, ['email', 'userid', 'nickname']) return render_template('index.html', user=user)
def dologin(): email = request.form['email'] passwd = request.form['password'] user_model = UserModel(app.config['MYSQL_AGENT']) user = user_model.query_user('email', email, ['email', 'password', 'userid']) if user: session['uid'] = user['userid'] return redirect('/') return "用户名不存在"
def regist(): if request.method == 'GET': return render_template("regist.tpl.html") user_model = UserModel(app.config['MYSQL_AGENT']) user_info = {'email' : request.form['email'], 'nickname' : request.form['nickname'], 'passwd' : request.form['password'] } user = user_model.create_user(user_info) session['uid'] = user['userid'] return redirect(url_for('/'))
def regist(): if request.method == 'GET': return render_template("regist.tpl.html") user_model = UserModel(app.config['MYSQL_AGENT']) user_info = { 'email': request.form['email'], 'nickname': request.form['nickname'], 'passwd': request.form['password'] } user = user_model.create_user(user_info) session['uid'] = user['userid'] return redirect(url_for('/'))