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

def validateLogin():

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

        cursor = con.cursor()
        data = cursor.fetchall()

direct to another page

def school():
if session.get('user'):
    return redirect('/getSchoolList')
    return redirect('/')

@app.route('/getSchoolList', methods=['POST','GET'])
def showSchoolList():
    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)
        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:

got it! Thanks.

Excellent. Glad to help.