From 9b4e56a94eeebf8264dfd55c2efe7de2265594bc Mon Sep 17 00:00:00 2001 From: Toy Rik Date: Sat, 30 Aug 2025 15:55:33 +0300 Subject: [PATCH] =?UTF-8?q?=D1=88=D0=B0=D0=B1=D0=BB=D0=BE=D0=BD=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .flaskenv.example | 1 + .gitignore | 1 + app/routes.py | 15 ++++++++++++++- app/templates/base.html | 15 +++++++++++++++ app/templates/index.html | 7 +++++++ 5 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 .flaskenv.example create mode 100644 app/templates/base.html create mode 100644 app/templates/index.html diff --git a/.flaskenv.example b/.flaskenv.example new file mode 100644 index 0000000..a148227 --- /dev/null +++ b/.flaskenv.example @@ -0,0 +1 @@ +FLASK_APP=microblog.py \ No newline at end of file diff --git a/.gitignore b/.gitignore index 821cb3e..60ff444 100644 --- a/.gitignore +++ b/.gitignore @@ -55,3 +55,4 @@ instance/ # Flask specific webassets/ +/.flask.env diff --git a/app/routes.py b/app/routes.py index 1e492b0..a0f9021 100644 --- a/app/routes.py +++ b/app/routes.py @@ -1,5 +1,18 @@ +from flask import render_template from app import app + @app.route('/') @app.route('/index') def index(): - return "Hello, word!" \ No newline at end of file + user = {'username': 'Miguel'} + posts = [ + { + 'author': {'username': 'John'}, + 'body': 'Beautiful day in Portland!' + }, + { + 'author': {'username': 'Susan'}, + 'body': 'The Avengers movie was so cool!' + } + ] + return render_template('index.html', title='Home', user=user, posts=posts) \ No newline at end of file diff --git a/app/templates/base.html b/app/templates/base.html new file mode 100644 index 0000000..2d78870 --- /dev/null +++ b/app/templates/base.html @@ -0,0 +1,15 @@ + + + + {% if title %} + {{ title }} - Microblog + {% else %} + Welcome to Microblog + {% endif %} + + +
Microblog: Home
+
+ {% block content %}{% endblock %} + + diff --git a/app/templates/index.html b/app/templates/index.html new file mode 100644 index 0000000..0b3ac7b --- /dev/null +++ b/app/templates/index.html @@ -0,0 +1,7 @@ +{% extends "base.html" %} +{% block content %} +

Hi, {{ user.username }}!

+ {% for post in posts %} +

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

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