JEbert
JEbert

Reputation: 21

How to resolve a flask app that is not able to locate HTML document in the templates folder resulting in an internal sever error

This is the full error we receive when running the flask application in the browser.

"Internal 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've done some research and have already attempted to link the folder with the app = Flask(__name__, template_folder='/templates') assignment.

Here is my directory and debug logs. Any insight would be appreciated.

Directory

Logs

Upvotes: 1

Views: 269

Answers (2)

IoaTzimas
IoaTzimas

Reputation: 10624

Your code needs some changes. First of all, try using

render_template('prediction.html')

instead of

render_template('templates/prediction.html')

as Flasks already looks at templates folder (which in this case means that it will look for a folder 'templates' inside the folder 'templates')

If this doesn't work, try the same but when you declare the folder do it by:

app = Flask(__name__, template_folder='/templates')

(with '/' before templates) and not your current

app = Flask(__name__, template_folder='templates')

If nothing of the above works, just the same solutions, without declaring template_folder at all, as by default Flask looks in the folder named 'templates'

Upvotes: 0

azibom
azibom

Reputation: 1934

try it app = Flask(__name__, template_folder='templates')

Upvotes: 1

Related Questions