Make it possible to load configuration from a Python file #3
2
.gitignore
vendored
2
.gitignore
vendored
@ -1 +1 @@
|
||||
__pycache__/
|
||||
__pycache__/
|
||||
|
@ -14,13 +14,18 @@
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
import os
|
||||
|
||||
from flask import Flask, render_template
|
||||
|
||||
|
||||
class CalendarSocialApp(Flask):
|
||||
def __init__(self, name):
|
||||
def __init__(self, name, config=None):
|
||||
Flask.__init__(self, name)
|
||||
|
||||
config_name = os.environ.get('ENV', config or 'dev')
|
||||
self.config.from_pyfile(f'config_{config_name}.py', True)
|
||||
|
||||
|
||||
app = CalendarSocialApp(__name__)
|
||||
|
||||
|
2
app/config_dev.py
Normal file
2
app/config_dev.py
Normal file
@ -0,0 +1,2 @@
|
||||
DEBUG = True
|
||||
ENV = 'dev'
|
Loading…
Reference in New Issue
Block a user