forked from michaljemala/hello-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhello.py
More file actions
43 lines (34 loc) · 789 Bytes
/
hello.py
File metadata and controls
43 lines (34 loc) · 789 Bytes
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
import os
import uuid
from flask import Flask
app = Flask(__name__)
my_uuid = str(uuid.uuid1())
BLUE = "#0099FF"
GREEN = "#33CC33"
GRAY = "808080"
COLOR = GRAY
def getcounter():
with open('counter', 'r+') as f:
counter = int(f.readline())
return counter
def updatecounter(count):
with open('counter', 'w+') as f:
f.write(str(count+1))
@app.route('/')
def hello():
count = getcounter()
updatecounter(count)
return """
<html>
<body bgcolor="{}">
<center><h1><font color="white">Hi, I'm GUID:<br/>
{}</br>
<br>
<br>
Visits: {}
</center>
</body>
</html>
""".format(COLOR,my_uuid,count)
if __name__ == "__main__":
app.run(debug=True,host='0.0.0.0', port=int(os.getenv('VCAP_APP_PORT', '5000')))