【发布时间】:2015-12-01 10:25:52
【问题描述】:
基本上只是尝试制作一个几乎没有安全性但不断收到内部服务器错误的简单登录页面,如果我出错了,任何帮助将不胜感激。我试过四处寻找,但找不到任何东西。我对 Python 也很陌生,所以放轻松:)
Python/Flask:
@app.route('/adminlogin')
def admin():
return render_template('adminlogin.html')
@app.route('/adminDetails', methods =['POST'])
def adminLogin():
correctUser = 'admin'
correctPass = 'Password1'
username = request.form['username']
password = request.form['password']
if username == correctUser & password == correctPass:
adminSuccess()
else:
admin()
@app.route('/admin')
def adminSuccess():
return render_template('admin.html')
HTML:
<form action="/adminDetails" method="post">
Username<input name="username" type = "text" maxlength="32" size="12" placeholder="Username" required><br>
Password<input name ="password" type="password" maxlength="20" size="12" placeholder="Password" required><br>
<button class ="menuitem" type="submit" value="submit">Submit</button>
<button class="menuitem" type ="reset" value ="Clear">Clear</button>
</form>
追溯:
Traceback (most recent call last):
File "C:\Users\\AppData\Local\Programs\Python\Python35-32\lib\site- packages\flask\app.py", line 1836, in __call__
return self.wsgi_app(environ, start_response)
File "C:\Users\\AppData\Local\Programs\Python\Python35-32\lib\site-packages\flask\app.py", line 1820, in wsgi_app
response = self.make_response(self.handle_exception(e))
File "C:\Users\\AppData\Local\Programs\Python\Python35-32\lib\site-packages\flask\app.py", line 1403, in handle_exception
reraise(exc_type, exc_value, tb)
File "C:\Users\\AppData\Local\Programs\Python\Python35-32\lib\site-packages\flask\_compat.py", line 33, in reraise
raise value
File "C:\Users\\AppData\Local\Programs\Python\Python35-32\lib\site-packages\flask\app.py", line 1817, in wsgi_app
response = self.full_dispatch_request()
File "C:\Users\\AppData\Local\Programs\Python\Python35-32\lib\site-packages\flask\app.py", line 1478, in full_dispatch_request
response = self.make_response(rv)
File "C:\Users\\AppData\Local\Programs\Python\Python35-32\lib\site-packages\flask\app.py", line 1566, in make_response
raise ValueError('View function did not return a response')
ValueError: View function did not return a response
【问题讨论】:
-
请阅读错误信息。他们大概会告诉您
Password1没有定义,但事实并非如此。您希望该变量的值来自哪里? -
来自 HTML 中的表单?
-
哦等等,我明白你的意思了。
标签: python flask internal-server-error