diff --git a/Dockerfile b/Dockerfile index 4d8f801..2778af7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ FROM python:slim RUN pip install flask COPY /beer/beer.py /beer.py -COPY /beer/static /static +COPY /beer/templates /templates COPY /beer/static /static EXPOSE 5000 diff --git a/beer/beer.py b/beer/beer.py index 9040d40..f8fe914 100755 --- a/beer/beer.py +++ b/beer/beer.py @@ -28,9 +28,18 @@ def index(hours=None, minutes=None): @app.route('/favicon.ico') def favicon(): - """ serve the favicon """ + """ serve default favicon """ return send_from_directory('static', 'clock-icon.png') +@app.route('/favicon/') +def favicon(): + """ serve the favicon according to the timer """ + if mode == 'beer': + return send_from_directory('static', 'beer-icon.png') + else: + return send_from_directory('static', 'clock-icon.png') + + def main(): """ main func """ app.run(host='::') diff --git a/beer/templates/beer.html b/beer/templates/beer.html index 4f56f8a..7685d42 100644 --- a/beer/templates/beer.html +++ b/beer/templates/beer.html @@ -85,7 +85,7 @@ var x = setInterval(function() { if (distance < 0) { clearInterval(x); document.getElementById("demo").innerHTML = "BEER TIME !"; - changeFavicon('beer-icon.png') + changeFavicon('/favicon/beer') } }, 1000);