Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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')


@app.route("/")
def startService():
    return "Simple Web app"

@app.route("/home")
def ohok():
    return render_template('home.html')

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

app directory

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading