Issue
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)
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
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
Answered By - NoNameI
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.