Skip to content
Snippets Groups Projects
Commit 4f4d5783 authored by Tomas Berger's avatar Tomas Berger
Browse files

Add app file

parent f75be484
No related branches found
No related tags found
No related merge requests found
app.py 0 → 100644
import time
import redis
from flask import Flask
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)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment