Flask login code

Do you know if something in this code could be wrong?
Everything works great for me and without errors locally but when I upload it to the hosting it gives me Internal Server Error (the logs still have to be sent to me if they exist), for my part I don’t see anything else on the screen.

The web goes correctly to the login template and from there it should redirect to home assuming that you write the username / password correctly

@app.route("/login", methods=['GET', 'POST'])
def login():
    if request.method == 'POST':
        #print(request.form['username'])
        # print(request.form['password'])
        user = User(0,request.form['username'],request.form['password'])
        logged_user=ModelUser.login(db,user)
        if logged_user != None:
            if logged_user.password:
                login_user(logged_user)
                #print(user.username)
                return redirect(url_for('home'))
            else:
                flash("invalid password")
                return render_template('login.html')
        else:
            flash("User not found")
            return render_template('login.html')
    else:
        return render_template('login.html')