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['password'])
        user = User(0,request.form['username'],request.form['password'])
        if logged_user != None:
            if logged_user.password:
                return redirect(url_for('home'))
                flash("invalid password")
                return render_template('login.html')
            flash("User not found")
            return render_template('login.html')
        return render_template('login.html')