Skip to content
This repository has been archived by the owner on Mar 19, 2020. It is now read-only.

Commit

Permalink
Fix "Deploy to Heroku" button
Browse files Browse the repository at this point in the history
Prior to this patch, Gavel crashed when run on Heroku because there was
no 'config.yaml' file present.
  • Loading branch information
anishathalye committed Jul 31, 2016
1 parent 43094b7 commit 4dba431
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ the required settings (the ones that don't have default values).
Most settings can either be set in `config.yaml` or set as environment
variables. There's more detailed documentation in `config.sample.yaml`.

If you don't want to use the config file and use only environment variables,
set the environment variable `IGNORE_CONFIG_FILE=true`.

## Use

Using the admin interface on `/admin`, input data for all the projects and
Expand Down
3 changes: 2 additions & 1 deletion app.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"description": "An awesome judging system for hackathons",
"env": {
"ADMIN_PASSWORD": "change-this-before-deploying",
"SECRET_KEY": "randomly-generate-this-before-deploying"
"SECRET_KEY": "randomly-generate-this-before-deploying",
"IGNORE_CONFIG_FILE": "true"
},
"keywords": [
"gavel",
Expand Down
1 change: 1 addition & 0 deletions gavel.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = DB_URI
app.config['SECRET_KEY'] = SECRET_KEY
db.app = app
db.init_app(app)

@app.route('/')
Expand Down
7 changes: 5 additions & 2 deletions settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@
class Config(object):

def __init__(self, config_file):
with open(config_file) as f:
self._config = yaml.safe_load(f)
if not os.environ.get('IGNORE_CONFIG_FILE', False):
with open(config_file) as f:
self._config = yaml.safe_load(f)
else:
self._config = {}

# checks for an environment variable first, then an entry in the config file,
# and then falls back to default
Expand Down

0 comments on commit 4dba431

Please sign in to comment.