From ec8ab8e9828920b98ef099d18447e0a147a54e37 Mon Sep 17 00:00:00 2001 From: Julio Biason Date: Thu, 18 Jul 2013 10:03:18 -0300 Subject: [PATCH] starting to load blueprints. display fails due the lack of templates (which I will fix next) --- lyrics/__init__.py | 15 +++++++++++++++ lyrics/blueprints/__init__.py | 0 lyrics/blueprints/index.py | 11 +++++++++++ 3 files changed, 26 insertions(+) create mode 100644 lyrics/blueprints/__init__.py create mode 100644 lyrics/blueprints/index.py diff --git a/lyrics/__init__.py b/lyrics/__init__.py index 5cc1e38..43b5f2c 100644 --- a/lyrics/__init__.py +++ b/lyrics/__init__.py @@ -12,6 +12,21 @@ import logging _log = logging.getLogger('lyrics') app = Flask(__name__) +app.config['SIDEBAR'] = [] + +# ---------------------------------------------------------------------- +# Import and register blueprints +# ---------------------------------------------------------------------- + +from lyrics.blueprints.index import index + +blueprints = [(index, '/', 'Index')] + +for (blueprint, path, title) in blueprints: + _log.debug('{blueprint} => "{path}" as "{title}"'.format( + blueprint=blueprint, path=path, title=title)) + app.register_blueprint(blueprint, url_prefix=path) + app.config['SIDEBAR'].append((title, path)) # ---------------------------------------------------------------------- # Start as application diff --git a/lyrics/blueprints/__init__.py b/lyrics/blueprints/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/lyrics/blueprints/index.py b/lyrics/blueprints/index.py new file mode 100644 index 0000000..f62207d --- /dev/null +++ b/lyrics/blueprints/index.py @@ -0,0 +1,11 @@ +#!/usr/bin/env python +# -*- encoding: utf-8 -*- + +from flask import Blueprint +from flask import render_template + +index = Blueprint('index', __name__) + +@index.route('/') +def root(): + return render_template('index.html')