-
Notifications
You must be signed in to change notification settings - Fork 6
/
main.py
35 lines (29 loc) · 1.02 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from flask import Flask, request, render_template
import socket
import sys
import os
app = Flask(__name__)
# Load configurations
app.config.from_pyfile('config_file.cfg')
button1 = app.config['VOTE1VALUE']
button2 = app.config['VOTE2VALUE']
title = app.config['TITLE']
# Change title to host name to demo NLB
if app.config['SHOWHOST'] == "true":
title = socket.gethostname()
@app.route('/', methods=['GET', 'POST'])
def index():
# Vote tracking
vote1 = 0
vote2 = 0
if request.method == 'GET':
# Return index with values
return render_template("index.html", value1=vote1, value2=vote2, button1=button1, button2=button2, title=title)
if __name__ == "__main__":
if os.environ.get('ENVIRONMENT') is not None:
if os.environ['ENVIRONMENT'] in ['PRODUCTION', 'production']:
app.run(host='0.0.0.0', debug=True, port=80)
else:
app.run(host='0.0.0.0', debug=True, port=5000)
else:
app.run(host='0.0.0.0', debug=True, port=5000)