|
|
@ -162,9 +162,14 @@ modules in the application (`__init__.py`) like this:: |
|
|
|
from yourapplication.views.frontend import frontend |
|
|
|
from yourapplication.views.frontend import frontend |
|
|
|
|
|
|
|
|
|
|
|
app = Flask(__name__) |
|
|
|
app = Flask(__name__) |
|
|
|
app.register_module(admin) |
|
|
|
app.register_module(admin, url_prefix='/admin') |
|
|
|
app.register_module(frontend) |
|
|
|
app.register_module(frontend) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
We register the modules with the app so that it can add them to the |
|
|
|
|
|
|
|
URL map for our application. Note the prefix argument to the admin |
|
|
|
|
|
|
|
module: by default when we register a module, that module's end-points |
|
|
|
|
|
|
|
will be registered on `/` unless we specify this argument. |
|
|
|
|
|
|
|
|
|
|
|
So what is different when working with modules? It mainly affects URL |
|
|
|
So what is different when working with modules? It mainly affects URL |
|
|
|
generation. Remember the :func:`~flask.url_for` function? When not |
|
|
|
generation. Remember the :func:`~flask.url_for` function? When not |
|
|
|
working with modules it accepts the name of the function as first |
|
|
|
working with modules it accepts the name of the function as first |
|
|
|