Python Forum

Full Version: Flask basic help needed
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
when I run app.py and when i go to the browser, the text is not displayed

/Project_file/
├── app.py
└── templates/
├── base.html
└── index.html

from flask import Flask, render_template

app = Flask(__name__)

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


if __name__ == "__main__":
    app.run(debug=True)
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    {% block head %}{% endblock %}
</head>
<body>
    {% block body %}{% endblock %}
</body>
</html>
{% extends 'base.html' %}

{% block head %}
<title>Main page</title>
{% endblock %}

{% block body %}
<p>Welt!</p>
{% endblock %}
Been a while since I've messed with flask but, pretty sure base.html and index.html need to be in the templates folder
(Sep-09-2024, 05:08 PM)menator01 Wrote: [ -> ]Been a while since I've messed with flask but, pretty sure base.html and index.html need to be in the templates folder

Thanks for answer but they are already in the templates folder, I specified the path incorrectly on site but every html in the project in right place.