vendredi 29 janvier 2021

Python 3.8.5 Flask giving internal server error with WSGI application when template is called using render_template in VS Code - 500 server error

I have been following a YouTube tutorial made by Corey Schafer using Flask. I have reached the 2nd tutorial about using html templates, but that is the only place I have reached. This is the program I am running called hello.py:

from flask import Flask, render_template

app = Flask(__name__)

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

app.run()

This is the HTML file I have been using, called home.html:

<!DOCTYPE html>
<html>
  <head>
    <title>Flask Template Example</title>
</head>
<body>
    <div>
        <p></p>
    </div>
</body>
</html>

Whenever I try to run my code, I always get the error jinja2.exceptions.TemplateNotFound: template.html. I've tried to look at all possible solutions, but none have seemed to work. How could I fix this? I'm on a Windows 64-bit machine.




Aucun commentaire:

Enregistrer un commentaire