Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Flask basic help needed
#1
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 %}
Reply
#2
Been a while since I've messed with flask but, pretty sure base.html and index.html need to be in the templates folder
I welcome all feedback.
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags
Download my project scripts


Reply
#3
(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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Tornado / Flask help needed jogl 2 5,940 Aug-27-2017, 10:21 PM
Last Post: jogl

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020