From fed4454a0531395ad581538020bc9e4cbd1d2b90 Mon Sep 17 00:00:00 2001 From: finn Date: Thu, 1 Aug 2024 02:07:49 -0700 Subject: [PATCH] mg tut c2 --- backend/app/routes.py | 17 ++++++++++++++++- backend/app/templates/base.html | 16 ++++++++++++++++ backend/app/templates/index.html | 11 +++++++++++ 3 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 backend/app/templates/base.html create mode 100644 backend/app/templates/index.html diff --git a/backend/app/routes.py b/backend/app/routes.py index 05a0bd4..9a10401 100644 --- a/backend/app/routes.py +++ b/backend/app/routes.py @@ -1,7 +1,22 @@ +from flask import render_template from app import app @app.route('/') @app.route('/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) + diff --git a/backend/app/templates/base.html b/backend/app/templates/base.html new file mode 100644 index 0000000..920f44b --- /dev/null +++ b/backend/app/templates/base.html @@ -0,0 +1,16 @@ + + + + {% if title %} + {{ title }} - blog + {% else %} + Welcome to blog. + {% endif %} + + +
blgo: home
+
+ {% block content %}{% endblock %} + + + diff --git a/backend/app/templates/index.html b/backend/app/templates/index.html new file mode 100644 index 0000000..ab4fd46 --- /dev/null +++ b/backend/app/templates/index.html @@ -0,0 +1,11 @@ +{% extends "base.html" %} + +{% block content %} +

Helloo, {{ user.username }}!

+ {% for post in posts %} +

{{ post.author.username }} says: {{ post.body }}

+ {% endfor %} +{% endblock %} + + +