Python Flask HTML wird nicht angezeigtHTML

HTML-Programmierer
Anonymous
 Python Flask HTML wird nicht angezeigt

Post by Anonymous »

Ich folge einem Flask-Tutorial von YouTube und habe festgestellt, dass meine Webanwendung beim Ausführen meines Codes nichts ausgibt. Dies passiert jedoch nur, wenn ich versuche, HTML zu verwenden.
Unten ist der Code:

Code: Select all

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

posts = [
{
'author': 'Devo Developerr',
'title': 'Blog Post 1',
'content': 'First post content',
'date_posted': 'October 23, 2020'
},
{
'author': 'Jane Doe',
'title': 'Blog Post 2',
'content': 'Second post content',
'date_posted': 'April 21, 2020'
}
]

@app.route("/")
@app.route("/home")
def home():
return render_template('home.html', posts=posts)

@app.route("/about")
def about():
return render_template('about.html', title='About')

if __name__ == '__main__':
app.run(debug=True)
Dies ist meine Haupt-Flask-Datei.
Dies ist meine HTML-Datei, home.html

Code: Select all






{% for post in posts %}
{{ post.title }}
By {{ post.author }} on {{ post.fate_posted }}
{{ post.content }}
{% end for %}


Was die angestrebte Ausgabe ist:
Image

Was die aktuelle Ausgabe ist:
Image

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post