标签:else dir har pre ack 首页 style render dex
登录功能完成:
session:
登录功能完成:
1 @app.route(‘/login/‘, methods=[‘GET‘, ‘POST‘]) 2 def login(): 3 if request.method == ‘GET‘: 4 return render_template("login.html") 5 else: 6 username = request.form.get(‘username‘) 7 password = request.form.get(‘password‘) 8 user = User.query.filter(User.username == username).first() 9 if user: 10 if user.password == password: 11 return redirect(url_for(‘myweb‘)) 12 else: 13 return ‘密码错误‘ 14 else: 15 return ‘用户名不存在‘
1 <div class="logo_box"> 2 <h3 style="text-align: center">欢迎你</h3> 3 <form action="{{ url_for(‘login‘) }}" method="post"> 4 <div class="input_outer"> 5 <span class="u_user"></span> 6 <input id="uname" class="text" style="color: wheat" type="text" placeholder="请输入账号" name="username"> 7 </div> 8 <div class="input_outer"> 9 <span class="us_uer"></span> 10 <input id="upass" class="text" style="color:wheat ; position:absolute; z-index:100;" 11 value="" type="password" placeholder="请输入密码" name="password"> 12 </div> 13 <div class="errorText" id="error_box" style="color: red"><br></div> 14 <div> 15 <button onclick="return fnLogin()" class="lb1" style="color:black">登录</button> 16 </div> 17 </form> 18 </div>
session:
1 import os 2 DEBUG = True 3 4 SECRET_KEY = os.urandom(24) 5 6 DIALECT = ‘mysql‘ 7 DRIVER = ‘mysqldb‘ 8 USERNAME = ‘root‘ 9 PASSWORD = ‘ROOT‘ 10 HOST = ‘127.0.0.1‘ 11 DATABASE = ‘mytest‘ 12 13 14 SQLALCHEMY_DATABASE_URI = ‘mysql+pymysql://root:@127.0.0.1:3306/mytest?charset=utf8‘ 15 SQLALCHEMY_TRACK_MODIFICATIONS = False
标签:else dir har pre ack 首页 style render dex
原文地址:http://www.cnblogs.com/-064/p/7875615.html