Forums

Randomly occur errors

My flask app occurs Internal server error randomly while I try login. Sometimes it succeeds login but sometimes it doesn't. As well as this error, if I log in, it doesn't reach other menus and it never happened when I tested on localhost. This server doesn't work properly. I don't know why.

validate login

@app.route('/validateLogin',methods=['GET','POST'])
def validateLogin():

try:
    if request.method=='POST':
        _username = request.form['id']
        _password = request.form['password']

        cursor = con.cursor()
        cursor.callproc('sp_validateLogin',(_username,))
        data = cursor.fetchall()

direct to another page

@app.route('/school')
def school():
if session.get('user'):
    return redirect('/getSchoolList')
else:
    return redirect('/')

@app.route('/getSchoolList', methods=['POST','GET'])
def showSchoolList():
try:
    if session.get('user'):
        ##con = mysql.connect()
        cursor = con.cursor()
        cursor.execute("select * from school")
        schoollist = cursor.fetchall()

        return render_template('/ann_school.html',schoollist=schoollist)
    else:
        return redirect('/error')
except Exception as e:
    return redirect('/error')

Once chrome console showed "violation DOMContentLoaded"

If your web app is returning server errors, you should look in your error log to see what they are. Then you can start working out what the problem is and how to fix it.

A quick glance at you code suggests one possibility to me: http://help.pythonanywhere.com/pages/ManagingDatabaseConnections/

got it! Thanks.

Excellent. Glad to help.