Ich bin mir nicht sicher, warum dieser Code mir einen 500 Fehler auf meiner Web-App mit Flask gibt, kann mir jemand sagen, wo meine Logik falsch ist? Ich habe das Gefühl, dass es mit den Funktionen von sha256_crypt.verify() zu tun hat, aber ich bin mir nicht sicher, wie ich das umgehen soll. Ich versuche nur, alle Daten eines Benutzers aus meinen Tabellen zu ziehen und sie in die Sitzungsvariable einzufügen. Lass es mich wissen, danke!500 Fehler mit MySQLdb Python beim Ziehen von Daten aus Tabellen
@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)
Log: (sorry nicht sicher, wie diese richtig schreiben)
.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/
Fügen Sie die Ausnahme von Ihren Protokollen. – jordanm
Fertig, tut mir leid, ich weiß nicht, ob das der richtige Weg ist, ein Fehlerprotokoll zu posten lol – douglasrcjames
Sie haben keine mod_wsgi-Konfiguration eingerichtet, um Python mitzuteilen, wo sich Ihr Projektcode befindet. Siehe http://flask.pocoo.org/docs/0.12/deploying/mod_wsgi/ –