шаблоны
This commit is contained in:
parent
a5f65ee9a8
commit
9b4e56a94e
1
.flaskenv.example
Normal file
1
.flaskenv.example
Normal file
@ -0,0 +1 @@
|
|||||||
|
FLASK_APP=microblog.py
|
||||||
1
.gitignore
vendored
1
.gitignore
vendored
@ -55,3 +55,4 @@ instance/
|
|||||||
|
|
||||||
# Flask specific
|
# Flask specific
|
||||||
webassets/
|
webassets/
|
||||||
|
/.flask.env
|
||||||
|
|||||||
@ -1,5 +1,18 @@
|
|||||||
|
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, word!"
|
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)
|
||||||
15
app/templates/base.html
Normal file
15
app/templates/base.html
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
{% if title %}
|
||||||
|
<title>{{ title }} - Microblog</title>
|
||||||
|
{% else %}
|
||||||
|
<title>Welcome to Microblog</title>
|
||||||
|
{% endif %}
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div>Microblog: <a href="/index">Home</a></div>
|
||||||
|
<hr>
|
||||||
|
{% block content %}{% endblock %}
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
7
app/templates/index.html
Normal file
7
app/templates/index.html
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{% extends "base.html" %}
|
||||||
|
{% block content %}
|
||||||
|
<h1>Hi, {{ user.username }}!</h1>
|
||||||
|
{% for post in posts %}
|
||||||
|
<div><p>{{ post.author.username }} says: <b>{{ post.body }}</b></p></div>
|
||||||
|
{% endfor %}
|
||||||
|
{% endblock %}
|
||||||
Loading…
x
Reference in New Issue
Block a user