forked from dineshsadasivam/demoapp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
35 lines (28 loc) · 897 Bytes
/
app.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
import os
from flask import Flask
from flask import render_template
import socket
import random
import os
app = Flask(__name__)
color_codes = {
"red": "#e74c3c",
"green": "#16a085",
"blue": "#2980b9",
}
color = os.environ.get('APP_COLOR') or random.choice(["red","green","blue"])
@app.route("/")
def main():
#return 'Hello'
print(color)
return render_template('hello.html', name=socket.gethostname(), color=color_codes[color])
@app.route('/color/<new_color>')
def new_color(new_color):
return render_template('hello.html', name=socket.gethostname(), color=color_codes[new_color])
@app.route('/read_file')
def read_file():
f = open("/data/testfile.txt")
contents = f.read()
return render_template('hello.html', name=socket.gethostname(), contents=contents, color=color_codes[color])
if __name__ == "__main__":
app.run(host="0.0.0.0", port="8080")