flask site buildout #2

Merged
finn merged 25 commits from mgtut1 into master 2024-08-05 08:41:03 +00:00
3 changed files with 43 additions and 1 deletions
Showing only changes of commit fed4454a05 - Show all commits

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 %}