Skip to content

Commit 55f62a0

Browse files
authored
Merge pull request #61 from Um9i/master
start app in production by default
2 parents b72f822 + bdf6f34 commit 55f62a0

File tree

6 files changed

+22
-7
lines changed

6 files changed

+22
-7
lines changed

{{cookiecutter.app_slug}}/.env

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
APP_NAME="{{cookiecutter.app_name}}"
2-
APP_SETTINGS="project.server.config.DevelopmentConfig"
3-
FLASK_DEBUG=1
2+
APP_SETTINGS="project.server.config.ProductionConfig"
3+
FLASK_DEBUG=0

{{cookiecutter.app_slug}}/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ services:
1515
- APP_NAME={{cookiecutter.app_name}}
1616
- FLASK_DEBUG=1
1717
- PYTHONUNBUFFERED=0
18-
- APP_SETTINGS=project.server.config.DevelopmentConfig
18+
- APP_SETTINGS=project.server.config.ProductionConfig
1919
- DATABASE_URL=postgres://postgres:postgres@web-db:5432/users_dev
2020
- DATABASE_TEST_URL=postgres://postgres:postgres@web-db:5432/users_test
2121
- SECRET_KEY=change_me_in_prod

{{cookiecutter.app_slug}}/project/server/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def create_app(script_info=None):
3232

3333
# set config
3434
app_settings = os.getenv(
35-
"APP_SETTINGS", "project.server.config.DevelopmentConfig"
35+
"APP_SETTINGS", "project.server.config.ProductionConfig"
3636
)
3737
app.config.from_object(app_settings)
3838

{{cookiecutter.app_slug}}/project/server/config.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,8 @@ class ProductionConfig(BaseConfig):
3939
"""Production configuration."""
4040

4141
BCRYPT_LOG_ROUNDS = 13
42-
SQLALCHEMY_DATABASE_URI = os.environ.get("DATABASE_URL")
42+
SQLALCHEMY_DATABASE_URI = os.environ.get(
43+
"DATABASE_URL",
44+
"sqlite:///{0}".format(os.path.join(basedir, "prod.db")),
45+
)
4346
WTF_CSRF_ENABLED = True

{{cookiecutter.app_slug}}/setup-with-docker.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ Update the environment variables in *docker-compose.yml*, and then build the ima
1212
$ docker-compose up -d --build
1313
```
1414

15+
By default the app is set to use the production configuration. If you would like to use the development configuration, you can alter the `APP_SETTINGS` environment variable:
16+
17+
```
18+
APP_SETTINGS="project.server.config.DevelopmentConfig"
19+
```
20+
21+
1522
Create the database:
1623
-
1724
```sh

{{cookiecutter.app_slug}}/setup-without-docker.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,18 @@ Update *project/server/config.py*, and then run:
1212

1313
```sh
1414
$ export APP_NAME="{{cookiecutter.app_name}}"
15+
$ export APP_SETTINGS="project.server.config.ProductionConfig"
16+
$ export FLASK_DEBUG=0
17+
```
18+
By default the app is set to use the production configuration. If you would like to use the development configuration, you can alter the `APP_SETTINGS` environment variable:
19+
20+
```sh
1521
$ export APP_SETTINGS="project.server.config.DevelopmentConfig"
16-
$ export FLASK_DEBUG=1
1722
```
1823

1924
Using [Pipenv](https://docs.pipenv.org/) or [python-dotenv](https://github.com/theskumar/python-dotenv)? Use the *.env* file to set environment variables:
2025

21-
```sh
26+
```
2227
APP_NAME="{{cookiecutter.app_name}}"
2328
APP_SETTINGS="project.server.config.DevelopmentConfig"
2429
FLASK_DEBUG=1

0 commit comments

Comments
 (0)