-
Notifications
You must be signed in to change notification settings - Fork 138
/
app.py
38 lines (31 loc) · 996 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
36
37
38
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",
"blue2": "#30336b",
"pink": "#be2edd",
"darkblue": "#130f40"
}
color = os.environ.get('APP_COLOR') or random.choice(["red","green","blue","blue2","darkblue","pink"])
@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")