Skip to content
Myr

Blueprint example app

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Dmitry Shevchenko · committed by Dmitry Shevchenko · parent 20a3281 · Browse files · 7 files+64 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

7 files+64 added−0 removed

  • other:+64 added−0 removed

7 files+64 added−0 removed

added:examples/blueprintexample/simple_page/templates/pages/hello.html+5 added
added:examples/blueprintexample/simple_page/templates/pages/index.html+5 added
added:examples/blueprintexample/simple_page/templates/pages/layout.html+25 added
added:examples/blueprintexample/simple_page/templates/pages/world.html+5 added
added:examples/blueprintexample/simple_page/__init__.py
added:examples/blueprintexample/simple_page/simple_page.py+13 added
1from flask import Blueprint, render_template, abort2from jinja2 import TemplateNotFound34simple_page = Blueprint('simple_page', __name__,5 template_folder='templates')67@simple_page.route('/', defaults={'page': 'index'})8@simple_page.route('/<page>')9def show(page):10 try:11 return render_template('pages/%s.html' % page)12 except TemplateNotFound:13 abort(404)
added:examples/blueprintexample/blueprintexample.py+11 added
1from flask import Flask2from simple_page.simple_page import simple_page34app = Flask(__name__)5app.register_blueprint(simple_page)6# Blueprint can be registered many times7app.register_blueprint(simple_page, url_prefix='/pages') 8910if __name__ == '__main__':11 app.run(debug=True)