Use FLASK_DEBUG instead of MYFLASKAPP_ENV

Use the new FLASK_DEBUG environment variable
which is standard as of Flask 0.11, in order
to control the use of dev or prod config.

Need to set this anyway, in order for "flask run"
to use reloader and no concurrency.
master
Jeremy Epstein 8 years ago
parent d23a3c455b
commit 4c856777f1
  1. 5
      README.rst
  2. 13
      {{cookiecutter.app_name}}/README.rst
  3. 4
      {{cookiecutter.app_name}}/autoapp.py

@ -70,6 +70,11 @@ BSD licensed.
Changelog Changelog
--------- ---------
0.10.2 (09/10/2016)
*******************
- Use the FLASK_DEBUG system environment variable, instead of MYFLASKAPP_ENV, to control different configs for development and production environments
0.10.1 (08/28/2016) 0.10.1 (08/28/2016)
******************* *******************

@ -8,15 +8,18 @@
Quickstart Quickstart
---------- ----------
First, set your app's secret key as an environment variable. For example, example add the following to ``.bashrc`` or ``.bash_profile``. First, set your app's secret key as an environment variable. For example,
add the following to ``.bashrc`` or ``.bash_profile``.
.. code-block:: bash .. code-block:: bash
export {{cookiecutter.app_name | upper}}_SECRET='something-really-secret' export {{cookiecutter.app_name | upper}}_SECRET='something-really-secret'
Before running shell commands, set the ``FLASK_APP`` environment variable :: Before running shell commands, set the ``FLASK_APP`` and ``FLASK_DEBUG``
environment variables ::
export FLASK_APP=/path/to/autoapp.py export FLASK_APP=/path/to/autoapp.py
export FLASK_DEBUG=1
Then run the following commands to bootstrap your environment :: Then run the following commands to bootstrap your environment ::
@ -28,7 +31,8 @@ Then run the following commands to bootstrap your environment ::
You will see a pretty welcome screen. You will see a pretty welcome screen.
Once you have installed your DBMS, run the following to create your app's database tables and perform the initial migration :: Once you have installed your DBMS, run the following to create your app's
database tables and perform the initial migration ::
flask db init flask db init
flask db migrate flask db migrate
@ -39,7 +43,8 @@ Once you have installed your DBMS, run the following to create your app's databa
Deployment Deployment
---------- ----------
In your production environment, make sure the ``{{cookiecutter.app_name|upper}}_ENV`` environment variable is set to ``"prod"``. In your production environment, make sure the ``FLASK_DEBUG`` environment
variable is unset or is set to ``0``, so that ``ProdConfig`` is used.
Shell Shell

@ -1,10 +1,10 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
"""Create an application instance.""" """Create an application instance."""
import os from flask.helpers import get_debug_flag
from {{cookiecutter.app_name}}.app import create_app from {{cookiecutter.app_name}}.app import create_app
from {{cookiecutter.app_name}}.settings import DevConfig, ProdConfig from {{cookiecutter.app_name}}.settings import DevConfig, ProdConfig
CONFIG = ProdConfig if os.environ.get('{{cookiecutter.app_name | upper}}_ENV') == 'prod' else DevConfig CONFIG = DevConfig if get_debug_flag() else ProdConfig
app = create_app(CONFIG) app = create_app(CONFIG)

Loading…
Cancel
Save