Skip to content

Commit 631fc37

Browse files
committed
Add template inheritance
1 parent 2814e21 commit 631fc37

12 files changed

+92
-0
lines changed

.flaskenv

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
FLASK_APP=flask_auth.py
2+
FLASK_ENV=development
3+
FLASK_DEBUG=True

__pycache__/flask_auth.cpython-38.pyc

210 Bytes
Binary file not shown.

app/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from flask import Flask
2+
from flask_bootstrap import Bootstrap
3+
4+
app = Flask(__name__)
5+
bootstrap = Bootstrap(app)
6+
7+
from app import routes, models, errors
381 Bytes
Binary file not shown.

app/__pycache__/errors.cpython-38.pyc

186 Bytes
Binary file not shown.

app/__pycache__/models.cpython-38.pyc

186 Bytes
Binary file not shown.

app/__pycache__/routes.cpython-38.pyc

434 Bytes
Binary file not shown.

app/routes.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from app import app
2+
from flask import render_template
3+
4+
5+
@app.route('/')
6+
@app.route('/index')
7+
def index():
8+
return render_template('index.html', title='Home')

app/templates/base.html

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{% extends 'bootstrap/base.html' %}
2+
3+
{% block title %}
4+
{% if title %}
5+
{{ title }} - Flask Auth
6+
{% else %}
7+
Welcome to Third Party Authentication
8+
{% endif %}
9+
{% endblock %}
10+
11+
{% block navbar %}
12+
<nav class="navbar navbar-default">
13+
<div class="container">
14+
<div class="navbar-header">
15+
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
16+
<span class="sr-only">Toggle navigation</span>
17+
<span class="icon-bar"></span>
18+
<span class="icon-bar"></span>
19+
<span class="icon-bar"></span>
20+
</button>
21+
<a class="navbar-brand" href="{{ url_for('index') }}">Flask Auth</a>
22+
</div>
23+
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
24+
<ul class="nav navbar-nav">
25+
<li><a href="{{ url_for('index') }}">Home</a></li>
26+
</ul>
27+
</div>
28+
</div>
29+
</nav>
30+
{% endblock %}
31+
32+
{% block content %}
33+
<div class="container">
34+
{% with messages = get_flashed_messages() %}
35+
{% if messages %}
36+
{% for message in messages %}
37+
<div class="alert alert-info" role='alert'>
38+
{{ message }}
39+
</div>
40+
{% endfor %}
41+
{% endif %}
42+
{% endwith %}
43+
44+
{% block app_content %}{% endblock %}
45+
</div>
46+
{% endblock %}

app/templates/index.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{% extends 'base.html' %}
2+
3+
{% block app_content %}
4+
<h1>Hi, you!</h1>
5+
{% endblock %}

0 commit comments

Comments
 (0)