Skip to content

Commit e9ed899

Browse files
committed
added environment variables for config
1 parent 5643ad8 commit e9ed899

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 configu 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:
14+
button1 = os.environ['VOTE1VALUE']
15+
else:
16+
button1 = app.config['VOTE1VALUE']
17+
18+
if "VOTE2VALUE" in os.environ:
19+
button2 = os.environ['VOTE2VALUE']
20+
else:
21+
button2 = app.config['VOTE2VALUE']
22+
23+
if "TITLE" in os.environ:
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)