the routers.py file
from flask import render_template from blog import app @app.route("/") def homepage(): posts = [ {"title": "Post nr. 1", "body": "This is the first post of my blog", "author": "Giovanni Pyhton", "date": "06/07/2019"}, {"title": "Post. nr.2", "body": "Hello... we're back, with the second post", "author": "Giovanni Pyhton", "date": "06/07/2019"} ] author = True date = False return render_template("homepage.html", posts=posts, author=author, date=date)
The homepage.html
<html> <style> body { color: coral; background-color: black; } </style> <body> <h1>Welcome to our Homepage</h1> {% for post in posts %} <h3> {{ post.title }}</h3> <p>{{ post.body }}</p> {% if author %} <span style="font-size:0.5em;color:yellowgreen">{{ post.author }} </span> {% endif %} {% if date %} <span style="font-size:0.5em;color:yellowgreen">{{ post.date }}</span> {% endif %} {% endfor %} </body> </html>