Updated documentation once more for new cli.

This commit is contained in:
Armin Ronacher 2014-04-29 01:03:32 +02:00
parent a3a5075a94
commit a3ad5405a6
4 changed files with 41 additions and 6 deletions

View file

@ -99,3 +99,32 @@ The command will then show up on the command line::
$ flask -a hello.py initdb
Init the db
Factory Functions
-----------------
In case you are using factory functions to create your application (see
:ref:`app-factories`) you will discover that the ``flask`` command cannot
work with them directly. Flask won't be able to figure out how to
instanciate your application properly by itself. Because of this reason
the recommendation is to create a separate file that instanciates
applications.
For instance if you have a factory function that creates an application
from a filename you could make a separate file that creates such an
application from an environment variable.
For instance this could be a file named ``autoapp.py`` with these
contents::
import os
from yourapplication import create_app
app = create_app(os.environ['YOURAPPLICATION_CONFIG'])
Once this has happened you can make the flask command automatically pick
it up::
export YOURAPPLICATION_CONFIG=/path/to/config.cfg
export FLASK_APP=/path/to/autoapp.py
From this point onwards ``flask`` will find your application.