added zeo_db

This commit is contained in:
Andreas Balogh
2021-02-10 22:07:06 +01:00
parent c73c9dd2ac
commit 0607e62300
10 changed files with 217 additions and 17 deletions

View File

@@ -0,0 +1,26 @@
import time
from flask import Flask
import redis
app = Flask(__name__)
cache = redis.Redis(host='redis', port=6379)
def get_hit_count():
retries = 5
while True:
try:
return cache.incr('hits')
except redis.exceptions.ConnectionError as exc:
if retries == 0:
raise exc
retries -= 1
time.sleep(0.5)
@app.route('/')
def hello():
count = get_hit_count()
return 'Hello World! I have been seen {} times.\n'.format(count)