How to call an app.route from the function of another webpage

I am creating a login page, so if login details are correct, I want the function to open up the app.route of the page the user is trying to login to. My code currently looks like this:

    aUsername = request.form['username']
    aPassword = request.form['password']
    cursor.execute("SELECT password FROM tblLogin WHERE username =" + "'" + aUsername + "'")
    correctPassword = cursor.fetchone()
    if correctPassword == None:
        return "username not found in system"
    elif aPassword != correctPassword[0]:
        return 'username and password do not match'

but I dont know what should go after the else. Please help me out!

The best way to do that is to send a redirect response, which will tell the browser "go to this URL". If you're using Flask (I'm guessing from your code that you are) then you would use the redirect function.

BTW I see that you are accessing the database directly from your code -- I'd recommend that you use a database connection manager like SQLAlchemy instead. Our Flask and MySQL tutorial has example code.