This is my Python code:
from flask import Flask, render_template
app = Flask(__name__)
@app.route("/profile/<name>")
def profile(name):
  return render_template("index.html", name=name)
if __name__ == "__main__":
  app.run()
and HTML code:
<!DOCTYPE html>
<html>
    <head>
    </head>
    <body>
        Hello {{ name }}
    </body>
</html>
And when I run the Python code, it shows on the browser that:
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 looked for the solution on Google as well as Youtube, but still can't fix it. Can someone help me with this? Thank you
Edit: so all I need to do is to fix this one line:
app = Flask(__name__, template_folder="template")
Whenever we receive 500 internal server error on a Python wsgi application we can log it using 'logging'
First import from logging import FileHandler,WARNING
then after app = Flask(__name__, template_folder = 'template')
add
file_handler = FileHandler('errorlog.txt')
file_handler.setLevel(WARNING)
Then you can run the application and when you receive a 500 Internal server error, cat/nano your errorlog.txt file to read it, which will show you what the error was caused by.
You must not had an empty line beetween
@app.route("/profile/<name>") and def profile(name):
You have to set the html file in a folder called templates.
You have to set the templates folder and run.py in the same folder
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With