I am new to flask and trying to deploy my webapp. I'm getting a 500 Internal Server Error on "/login" page. I don't know what's wrong with my code. The app runs fine on localhost. But when I deployed it on pythonanywhere it is throwing the error.
(I'm using sqlalchemy with sqlite and here is the '/login' and '/' route code snippet)
@app.route('/')
def home():
if not session.get('logged_in'):
return render_template('homepage.html')
else:
return render_template('quiz.html')
@app.route('/login', methods=['POST'])
def do_admin_login():
Session = sessionmaker(bind = engine)
s = Session()
global USERN
global PASSWD
POST_USERNAME = str(request.form['username']).lower()
USERN = POST_USERNAME
POST_PASSWORD = str(request.form['password'])
PASSWD = POST_PASSWORD
query = s.query(User).filter(User.username.in_([POST_USERNAME]),User.password.in_([POST_PASSWORD]))
result = query.first()
if result:
session['logged_in'] = True
else:
return 'wrong credentials'
return home()