0

I have just started my final project and am simply trying to allow users to login and register however, when I run flask, I get an error: jinja2.exceptions.TemplateNotFound: homepage.html although all the templates exist.

Here is part of application.py:

import os

from cs50 import SQL
from flask import Flask, flash, redirect, render_template, request, session
from flask_session import Session
from tempfile import mkdtemp
from werkzeug.exceptions import default_exceptions
from werkzeug.security import check_password_hash, generate_password_hash

from helpers import apology, login_required


app = Flask(__name__)

app.config["TEMPLATES_AUTO_RELOAD"] = True

@app.after_request
def after_request(response):
    response.headers["Cache-Control"] = "no-cache, no-store, must-revaliduate"
    response.headers["Expires"] = 0
    response.headers["Pragma"] = "no-cache"
    return response


app.config["SESSION_FILE_DIR"] = mkdtemp()
app.config["SESSION_PERMANENT"] = False
app.config["SESSION_TYPE"] = "filesystem"
Session(app)

db = SQL("sqlite:///project.db")

@app.route("/")
def homepage():
    """ Show welcome page """
    return render_template("cover.html")
5
  • The code does not mention a homepage.html. Are you sure code and error message match? Also, what's the relative path to your HTML file?
    – Blauelf
    Jul 31 '18 at 12:11
  • Sorry, the error is jinja2.exceptions.TemplateNotFound: cover.html - I miswrote it.
    – M. Alex
    Jul 31 '18 at 20:09
  • 1
    is your cover.html inside a folder named templates ?
    – curiouskiwi
    Aug 1 '18 at 0:45
  • All my HTML files for this project are in a folder called HTML. Does the folder have to be named templates?
    – M. Alex
    Aug 1 '18 at 7:42
  • I changed the folder name to templates and it's working now. Thanks
    – M. Alex
    Aug 1 '18 at 7:44

You must log in to answer this question.

Browse other questions tagged .