1
0
forked from finn/site

mg tut c2

This commit is contained in:
finn 2024-08-01 02:07:49 -07:00
parent becc234263
commit fed4454a05
3 changed files with 43 additions and 1 deletions

View File

@ -1,7 +1,22 @@
from flask import render_template
from app import app from app import app
@app.route('/') @app.route('/')
@app.route('/index') @app.route('/index')
def index(): def index():
return "Hello, World!"
user = {'username': 'Finnaa'}
posts = [
{
'author': {'username': 'john'},
'body': 'Beautiful day 1'
},
{
'author': {'username': 'susie'},
'body': 'Movie is good.'
}
]
#return posts;
return render_template('index.html', title='Home', user=user, posts=posts)

View File

@ -0,0 +1,16 @@
<!doctype html>
<html>
<head>
{% if title %}
<title>{{ title }} - blog</title>
{% else %}
<title>Welcome to blog.</title>
{% endif %}
</head>
<body>
<div>blgo: <a href="/index">home</a></div>
<hr>
{% block content %}{% endblock %}
</body>
</html>

View File

@ -0,0 +1,11 @@
{% extends "base.html" %}
{% block content %}
<h1>Helloo, {{ user.username }}!</h1>
{% for post in posts %}
<div><p>{{ post.author.username }} says: <b>{{ post.body }}</b></p></div>
{% endfor %}
{% endblock %}