我对烧瓶很陌生。 我有一个即将进行的项目,我正在使用一个模板来精美地创建我的登录页面。 我应该以管理员身份读取用户名,以管理员身份读取密码,并将其重定向到新页面,但是我无法解决问题。即使我也提交了表单,页面也没有变化。
HTML:
<div class="limiter">
<div class="container-login100">
<div class="wrap-login100">
<form class="login100-form validate-form" method="get" id="form1">
<span class="login100-form-title p-b-26">
Welcome
</span>
<span class="login100-form-title p-b-48">
<i class="zmdi zmdi-font"></i>
</span>
<div class="wrap-input100 validate-input" >
<input class="input100" type="text" name="username" value="{{ request.form.username }}">
<span class="focus-input100" data-placeholder="username" > </span>
</div>
<div class="wrap-input100 validate-input" >
<span class="btn-show-pass">
<i class="zmdi zmdi-eye"></i>
</span>
<input class="input100" type="password" name="password" value="{{ request.form.password }}" >
<span class="focus-input100" data-placeholder="password"></span>
</div>
<div class="container-login100-form-btn">
<div class="wrap-login100-form-btn">
<div class="login100-form-bgbtn"></div>
<button class="login100-form-btn" type="submit" form="form1" value="submit">
Login
</button>
</div>
</div>
</form>
</div>
</div>
</div>
烧瓶代码:
from flask import Flask, render_template, redirect, url_for, request,session,flash
from flask_bootstrap import Bootstrap
app = Flask(__name__)
Bootstrap(app)
@app.route('/adminhome')
def adminhome():
return "HEllo ADmin"
@app.route('/dealerhome')
def dealerhome():
return 'hello dealer'
@app.route('/', methods=['GET', 'POST'])
def login():
error = None
if request.method == 'POST':
if request.form['username'] == 'admin' and request.form['password'] == 'admin':
return redirect(url_for('adminhome'))
if request.form['username'] == 'dealer@gmail.com' and request.form['password'] == 'dealer':
return redirect(url_for('dealerhome'))
else:
error = 'Invalid Credentials. Please try again.'
return render_template('admin.html')
if __name__ == '__main__':
app.run(debug=True)
这是app.py的代码,第一个代码是html模板的代码
当我输入用户名和密码并按登录时,这会显示在终端上
"GET /?username=admin&password=admin HTTP/1.1" 200 -
我不明白那是什么
我认为表格未提交。