0
我不確定爲什麼這段代碼給了我一個與Flask的Web應用程序500錯誤,有人能告訴我我的邏輯錯在哪裏嗎?我有一種感覺,它與sha256_crypt.verify()函數有關,但不確定如何解決這個問題。試圖從我的表中拉出用戶的所有數據並將其放入會話變量中。讓我知道,謝謝!500錯誤MySQLdb Python從表中提取數據時
@app.route('/login/', methods=['GET','POST'])
def login_page():
error = ''
try:
c, conn = connection()
if request.method == "POST":
c.execute("SELECT * FROM clients WHERE email = (%s)", (thwart(request.form['email']),))
pdata = c.fetchone()[3]
if sha256_crypt.verify(request.form['password'], pdata):
#get info from clients table
c.execute("SELECT * FROM clients WHERE email = (%s)", (email,))
clients_results = fetchall()
clientcid = clients_results[0]
#get info from cpersonals table
c.execute("SELECT * FROM cpersonals WHERE cid = (%s)", (clientcid,))
cpersonals_results = fetchall()
conn.commit()
c.close()
conn.close()
session['logged_in'] = 'client'
session['clientcid'] = clientcid
session['email'] = email
session['phone'] = clients_results[1]
session['rating'] = clients_results[4]
session['first_name'] = cpersonals_results[1]
session['last_name'] = cpersonals_results[2]
session['address'] = cpersonals_results[3]
session['czip'] = cpersonals_results[4]
session['reg_date'] = cpersonals_results[5]
flash("You are now logged in.")
return redirect(url_for("ask"))
else:
error = "Invalid credentials, try again."
return render_template("login.html", error = error)
except Exception as e:
#flash(e)
error = "Invalid credentials, try again."
return render_template("login.html", error = error)
日誌:(抱歉不知道如何正確地張貼此)
.991239 mod_wsgi (pid=5585): Target WSGI script '/var/www/FlaskApp/flaskapp.wsgi' cannot be loaded as Python module., referer: http://138.197.210.172/view_unanswered/
.948625 mod_wsgi (pid=5585): Exception occurred processing WSGI script '/var/www/FlaskApp/flaskapp.wsgi'., referer: http://138.197.210.172/view_unanswered/
.948649 Traceback (most recent call last):, referer: http://138.197.210.172/view_unanswered/
.948670 File "/var/www/FlaskApp/flaskapp.wsgi", line 7, in <module>, referer: http://138.197.210.172/view_unanswered/
.948744 from FlaskApp import app as application, referer: http://138.197.210.172/view_unanswered/
.948857 File "/var/www/FlaskApp/FlaskApp/__init__.py", line 270, referer: http://138.197.210.172/view_unanswered/
.948869 conn.commit(), referer: http://138.197.210.172/view_unanswered/
.948873 ^, referer: http://138.197.210.172/view_unanswered/
.948877 IndentationError: unindent does not match any outer indentation level, referer: http://138.197.210.172/view_unanswered/
06.003866 mod_wsgi (pid=5586): Target WSGI script '/var/www/FlaskApp/flaskapp.wsgi' cannot be loaded as Python module., referer: http://138.197.210.172/account/
06.003919 mod_wsgi (pid=5586): Exception occurred processing WSGI script '/var/www/FlaskApp/flaskapp.wsgi'., referer: http://138.197.210.172/account/
06.003942 Traceback (most recent call last):, referer: http://138.197.210.172/account/
06.003964 File "/var/www/FlaskApp/flaskapp.wsgi", line 7, in <module>, referer: http://138.197.210.172/account/
06.004030 from FlaskApp import app as application, referer: http://138.197.210.172/account/
06.004076 File "/var/www/FlaskApp/FlaskApp/__init__.py", line 270, referer: http://138.197.210.172/account/
06.004083 conn.commit(), referer: http://138.197.210.172/account/
06.004087 ^, referer: http://138.197.210.172/account/
06.004090 IndentationError: unindent does not match any outer indentation level, referer: http://138.197.210.172/account/
09.513219 mod_wsgi (pid=5585): Target WSGI script '/var/www/FlaskApp/flaskapp.wsgi' cannot be loaded as Python module., referer: http://138.197.210.172/
09.513258 mod_wsgi (pid=5585): Exception occurred processing WSGI script '/var/www/FlaskApp/flaskapp.wsgi'., referer: http://138.197.210.172/
09.513280 Traceback (most recent call last):, referer: http://138.197.210.172/
09.513301 File "/var/www/FlaskApp/flaskapp.wsgi", line 7, in <module>, referer: http://138.197.210.172/
09.513335 from FlaskApp import app as application, referer: http://138.197.210.172/
09.513357 ImportError: cannot import name app, referer: http://138.197.210.172/
09.550576 mod_wsgi (pid=5586): Target WSGI script '/var/www/FlaskApp/flaskapp.wsgi' cannot be loaded as Python module., referer: http://138.197.210.172/view_unanswered/
09.550615 mod_wsgi (pid=5586): Exception occurred processing WSGI script '/var/www/FlaskApp/flaskapp.wsgi'., referer: http://138.197.210.172/view_unanswered/
09.550639 Traceback (most recent call last):, referer: http://138.197.210.172/view_unanswered/
09.550661 File "/var/www/FlaskApp/flaskapp.wsgi", line 7, in <module>, referer: http://138.197.210.172/view_unanswered/
09.550697 from FlaskApp import app as application, referer: http://138.197.210.172/view_unanswered/
09.550718 ImportError: cannot import name app, referer: http://138.197.210.172/view_unanswered/
12.922623 mod_wsgi (pid=5585): Target WSGI script '/var/www/FlaskApp/flaskapp.wsgi' cannot be loaded as Python module., referer: http://138.197.210.172/
12.922697 mod_wsgi (pid=5585): Exception occurred processing WSGI script '/var/www/FlaskApp/flaskapp.wsgi'., referer: http://138.197.210.172/
12.922743 Traceback (most recent call last):, referer: http://138.197.210.172/
12.922768 File "/var/www/FlaskApp/flaskapp.wsgi", line 7, in <module>, referer: http://138.197.210.172/
12.922807 from FlaskApp import app as application, referer: http://138.197.210.172/
12.922838 ImportError: cannot import name app, referer: http://138.197.210.172/
12.955475 mod_wsgi (pid=5586): Target WSGI script '/var/www/FlaskApp/flaskapp.wsgi' cannot be loaded as Python module., referer: http://138.197.210.172/
12.955537 mod_wsgi (pid=5586): Exception occurred processing WSGI script '/var/www/FlaskApp/flaskapp.wsgi'., referer: http://138.197.210.172/
12.955561 Traceback (most recent call last):, referer: http://138.197.210.172/
12.955584 File "/var/www/FlaskApp/flaskapp.wsgi", line 7, in <module>, referer: http://138.197.210.172/
12.955620 from FlaskApp import app as application, referer: http://138.197.210.172/
12.955641 ImportError: cannot import name app, referer: http://138.197.210.172/
異常從日誌粘貼。 – jordanm
完成,對不起,我不知道這是否是發佈錯誤日誌的正確方法lol – douglasrcjames
您還沒有設置mod_wsgi配置來告訴Python您的項目代碼所在的位置。參見http://flask.pocoo.org/docs/0.12/deploying/mod_wsgi/ –