forked from kontinu/container-expert-scratch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
50 lines (37 loc) · 1.21 KB
/
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
39
40
41
42
43
44
45
46
47
48
49
50
from flask import Flask
from flask import Flask, make_response, render_template
import os, platform
app = Flask(__name__)
#? BACK
kontinu_msg=os.getenv("MSG","< python: 🐳 Hello >")
# Use environment variables
#import extras.load_env
# load json config files
#import extras.config_file
# "/health"
import extras.health
# "/kontinu" in case
import extras.kontinu
# redis conn
from extras.redis_connect import nocache, get_hit_count
@app.route('/')
@nocache
def root():
count = get_hit_count()
host=platform.node()
foo=os.getenv('FOO', 'unset')
REDIS_HOST=os.getenv("REDIS_HOST",'')
DOCKER_SERVICE_NAME=os.getenv('DOCKER_SERVICE_NAME', host)
if "{{" in DOCKER_SERVICE_NAME or "}}" in DOCKER_SERVICE_NAME:
DOCKER_SERVICE_NAME="N/A"
#print(f"Getting visits! {count}")
global kontinu_msg
the_msg=""
try:
the_msg=kontinu_msg+extras.kontinu.get_next_msg()
except:
pass
return render_template('index.html',visit_counts=count, hostname=host, DOCKER_SERVICE_NAME=DOCKER_SERVICE_NAME, FOO=foo , redis_host=REDIS_HOST, greeting=the_msg)
if __name__ == '__main__':
print("==== Starting Python Server ====")
app.run(host='0.0.0.0',port=8080, debug=True)