示例#1
0
from flask_boilerplate_utils.overrides import NestableBlueprint
from flask.ext import menu
from flask_menu.classy import register_flaskview

frontend = NestableBlueprint('frontend',
                             __name__,
                             template_folder="templates",
                             static_folder="static")

from .controllers.Index import Index

Index.register(frontend)
register_flaskview(frontend, Index)

# Pragma - Submodule Registration Start
# Anything after the above line will be removed after cleanup.
from .modules.learn_flask import learn_flask
from .modules.examples import examples
from .modules.cleanup import cleanup

frontend.register_blueprint(learn_flask, url_prefix='/learn-flask')
frontend.register_blueprint(examples, url_prefix='/examples')
frontend.register_blueprint(cleanup, url_prefix='/cleanup')
示例#2
0
from flask_boilerplate_utils.overrides import NestableBlueprint
from flask_menu.classy import register_flaskview

submodule = NestableBlueprint('frontend.examples.submodule',
                              __name__,
                              template_folder="templates",
                              static_folder="static")
submodule.expected_parameters = ['id']

from .controllers.Index import Index
Index.register(submodule)
register_flaskview(submodule, Index)


@submodule.url_value_preprocessor
def validate_id(route, args):
    """
    Here we can validate the passed arguments
    """
    pass
示例#3
0
from flask_boilerplate_utils.overrides import NestableBlueprint

learn_flask = NestableBlueprint('frontend.learn_flask',
                                __name__,
                                template_folder="templates",
                                static_folder="static")

from .controllers.MainController import MainController

MainController.register(learn_flask)

from flask_menu.classy import register_flaskview

register_flaskview(learn_flask, MainController)

import os

examples_dir = os.path.realpath(
    os.path.join(os.path.realpath(__file__), '../python_examples/'))


@learn_flask.app_template_global('load_example_with_name')
def load_example_with_name(filename):
    fpath = os.path.join(examples_dir, filename)
    with open(fpath) as fh:
        return fh.read()