Skip to content

Commit ead2d84

Browse files
committed
Move app config to config module
1 parent 2bd7d64 commit ead2d84

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

service/__init__.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,27 +20,23 @@
2020
service
2121
models
2222
"""
23-
import os
2423
import sys
25-
import logging
2624
from flask import Flask
2725
from flask_restx import Api
2826
from service.common import log_handlers
27+
from service import config
2928

3029
# NOTE: Do not change the order of this code
3130
# The Flask app must be created
3231
# BEFORE you import modules that depend on it !!!
3332

3433
# Create the Flask app
3534
app = Flask(__name__)
35+
app.config.from_object(config)
3636

37+
# Turn off strict slashes because it violates best practices
3738
app.url_map.strict_slashes = False
3839

39-
app.config["SECRET_KEY"] = "secret-for-dev"
40-
app.config["LOGGING_LEVEL"] = logging.INFO
41-
app.config["API_KEY"] = os.getenv("API_KEY")
42-
app.config["ERROR_404_HELP"] = False
43-
4440
# Document the type of authorization required
4541
authorizations = {
4642
"apikey": {

service/config.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""
2+
Global Configuration for Application
3+
"""
4+
import os
5+
import logging
6+
7+
LOGGING_LEVEL = logging.INFO
8+
9+
# Secret for session management
10+
SECRET_KEY = os.getenv("SECRET_KEY", "sup3r-s3cr3t-for-dev")
11+
12+
# See if an API Key has been set for security
13+
API_KEY = os.getenv("API_KEY")
14+
15+
# Turn off helpful error messages that interfere with REST API messages
16+
ERROR_404_HELP = False

0 commit comments

Comments
 (0)