Skip to content

Instantly share code, notes, and snippets.

@diegoquintanav
Last active March 25, 2020 09:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save diegoquintanav/3d67393ba7624457ad703eeee320c152 to your computer and use it in GitHub Desktop.
Save diegoquintanav/3d67393ba7624457ad703eeee320c152 to your computer and use it in GitHub Desktop.
instance configuration in Flask
## instance/config.py
HELLO_ENABLED = False
from flask import Flask
import os
class Config:
"""basic configuration parameters passed to the Flask app"""
# basic config
SECRET_KEY = 'changeme'
WTF_CSRF_SECRET_KEY = 'changemetoo'
DEBUG=True
# application feature flags
HELLO_ENABLED = True
app = Flask(__name__, instance_relative_config=True)
app.config.from_object(Config)
# override default settings with those present in /instance/config.py
# this will raise an exception if file is not present
app.config.from_pyfile('config.py')
@app.route('/')
def hello_world():
if app.config['HELLO_ENABLED']:
return 'helloworld'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment