Skip to content

Commit 524a02a

Browse files
authored
Merge pull request #23 from neilpeterson/app-config-env-var
added environment variables for config
2 parents 5643ad8 + 89057c3 commit 524a02a

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

azure-vote/azure-vote/main.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,23 @@
77

88
app = Flask(__name__)
99

10-
# Load configurations
10+
# Load configurations from environment or config file
1111
app.config.from_pyfile('config_file.cfg')
12-
button1 = app.config['VOTE1VALUE']
13-
button2 = app.config['VOTE2VALUE']
14-
title = app.config['TITLE']
12+
13+
if ("VOTE1VALUE" in os.environ and os.environ['VOTE1VALUE']):
14+
button1 = os.environ['VOTE1VALUE']
15+
else:
16+
button1 = app.config['VOTE1VALUE']
17+
18+
if ("VOTE2VALUE" in os.environ and os.environ['VOTE2VALUE']):
19+
button2 = os.environ['VOTE2VALUE']
20+
else:
21+
button2 = app.config['VOTE2VALUE']
22+
23+
if ("TITLE" in os.environ and os.environ['TITLE']):
24+
title = os.environ['TITLE']
25+
else:
26+
title = app.config['TITLE']
1527

1628
# Redis configurations
1729
redis_server = os.environ['REDIS']

0 commit comments

Comments
 (0)