0

flaskblog.py contains the code

from flask import Flask, render_template
app = Flask(__name__)

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

@app.route('/about')
def about():
    return '<h1> About page!</h1>'


if __name__ == '__main__':
    app.run(debug= True)

home.html contains the code

<!DOCTYPE html>
<html>
<head>
    <title></title>
</head>
<body>
    <h1> Home Page! </h1>
</body>
</html>

When I run flaskblog.py, I get

 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)

When I put http://127.0.0.1:5000/ in safari, I get a page starts with

jinja2.exceptions.TemplateNotFound
2
  • 1
    What's your folders structure? is the home.html file inside the templates folder? Commented Jul 15, 2020 at 23:24
  • Yes it is inside. @luigibertaco Commented Jul 16, 2020 at 0:15

1 Answer 1

1

I've just executed your code locally with success, please doublecheck your file structure, it must be:

/flaskblog.py
/templates
    /home.html
Sign up to request clarification or add additional context in comments.

1 Comment

Hi @MustafaAlbairmani glad to help. if the answer helped, you can mark it as the correct solution to help other users that have the same problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.