Browse Source

Chapter 3: Templates with Flask-Bootstrap (3b)

master
T. Meissner 6 years ago
parent
commit
48b7c03532
2 changed files with 36 additions and 1 deletions
  1. +3
    -0
      hello.py
  2. +33
    -1
      templates/user.html

+ 3
- 0
hello.py View File

@ -1,7 +1,10 @@
from flask import Flask, render_template from flask import Flask, render_template
from flask_bootstrap import Bootstrap
app = Flask(__name__) app = Flask(__name__)
bootstrap = Bootstrap(app)
@app.route('/') @app.route('/')
def index(): def index():


+ 33
- 1
templates/user.html View File

@ -1 +1,33 @@
<h1>Hello, {{ name }}!</h1>
{% extends "bootstrap/base.html" %}
{% block title %}Flasky{% endblock %}
{% block navbar %}
<div class="navbar navbar-inverse" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle"
data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="/">Flasky</a>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li><a href="/">Home</a></li>
</ul>
</div>
</div>
</div>
{% endblock %}
{% block content %}
<div class="container">
<div class="page-header">
<h1>Hello, {{ name }}!</h1>
</div>
</div>
{% endblock %}

Loading…
Cancel
Save