我已经构建了一个非常简单的用户登录系统,没有数据库,但重定向又是一个问题。如果从HTML文件提交的用户名&密码是正确的,那么蟒蛇做以下的事情:Python烧瓶用户登录重定向
@app.route("/", methods=['GET', 'POST'])
def login_page():
if request.method == 'POST':
attempted_username = request.form['username']
attempted_password = request.form['password']
if attempted_username == 'admin' and attempted_password == 'password':
return redirect(url_for('index'))
else:
error='E-Mail or Password not available'
return render_template('login.html', error=error)
现在的网址将成为下一个:shost/index
和Chrome告诉我,然后
ERR_NAME_NOT_RESOLVED
The DNS address of the shost server couldnt be found.
为什么ISN这个URL变成了server_IP/index
,例如127.0.0.1/index
,因为这个在我的浏览器中有效。我怎样才能防止烧瓶问题shost
?
这里也是为登录的HTML表单代码:
<form class="text-left" method="post" action="">
<input class="mb0" type="text" placeholder="Username" name="username" value="{{request.form.username}}"/>
<input class="mb0" type="password" placeholder="Password" name="password" value="{{request.form.password}}"/>
<input type="submit" value="Login"/>
</form>
代码的@app.route("/index")
部分如下所示:
@app.route("/index")
def index():
return render_template('index.html')
非常感谢和问候
请包括'login_page'和'index'路线的其余部分。 –
@ edgaromar90感谢您的反馈。我添加了表单代码。 – saitam
我想我知道你的问题是什么。让我看看你的代码的'@ app.route(“/ index”)部分。 –