Flask render template doesn't render my html page keep getting "internal server error"

Running flask 2.1 w/ python 3.10 trying to create a small app

here’s my main.py file contents and directory setup

from waitress import serve
app = Flask(__name__, template_folder='/templates')

def startService():
    return "Simple Web app"

def ohok():
    return render_template('home.html')

if __name__ == "__main__":
    serve(app, host="", port=8080)

app directory

I have my home.html file correctly formatted placed in the templates folder, I also set the virtual environment, from terminal, my initial localhost:8080/ works but when I type the other directory localhost:8080/home it returns a "500 server error. The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application."

I use netstat -ano | findstr :8080 to see how many processes are being ran on that port and I get
cmd command showing processes ran on port 8080

Looked at many other similar questions, tried the follow solutions nothing works. Flask is installed in my python310 directory along with project folder

>Solution :

you don’t need to define host because localhost is the default value. Neither do you need to define template folder, just create one in the same place ass your app.py file. Delete that and there should be no problem, everything else is correct

Leave a Reply