From cb2552a7c39421eeab16a202797e1a3f5a3ba756 Mon Sep 17 00:00:00 2001 From: kleph Date: Wed, 8 Apr 2020 20:10:30 +0200 Subject: [PATCH 1/3] Change icon according to time --- beer/beer.py | 2 +- beer/static/{favicon.ico => beer-icon.png} | Bin beer/static/clock-icon.png | Bin 0 -> 5630 bytes beer/templates/beer.html | 18 +++++++++++++++++- 4 files changed, 18 insertions(+), 2 deletions(-) rename beer/static/{favicon.ico => beer-icon.png} (100%) create mode 100644 beer/static/clock-icon.png diff --git a/beer/beer.py b/beer/beer.py index ae3ddb8..9040d40 100755 --- a/beer/beer.py +++ b/beer/beer.py @@ -29,7 +29,7 @@ def index(hours=None, minutes=None): @app.route('/favicon.ico') def favicon(): """ serve the favicon """ - return send_from_directory('static', 'favicon.ico') + return send_from_directory('static', 'clock-icon.png') def main(): """ main func """ diff --git a/beer/static/favicon.ico b/beer/static/beer-icon.png similarity index 100% rename from beer/static/favicon.ico rename to beer/static/beer-icon.png diff --git a/beer/static/clock-icon.png b/beer/static/clock-icon.png new file mode 100644 index 0000000000000000000000000000000000000000..98485623265fd2ec26eb3c7a7e98125ba9f3bcb8 GIT binary patch literal 5630 zcmVO&3p|iN zDvF3wf(X((J|O|66F^FOHv7Ian+>~ZY@Iv1n=ilfo6YR(%$a+>d+)jDHYcipL&Hh5 z0u>MoyCuM*E&ZF|(1Je}N^^)e#0ydl;#Me(+(OBO+<;tyoQIq%lr!f}AN))7J6QuZ zPXHL&l{7}}1nCO#g**kR3E}UY&3r@wBoA^MauRX`@(W}ieVz>_330Vu- z3NqXit&ky5Gy!0A&ed%oZ$n;&)EBLjfw)E*BCLiS2N?=PD^wN~NdOqW3J(1s!H`~} z^)VAWAjzaD6|zJtQyhvS01WSr!)v55d>hgFSQy743m{*B2-%{Q(LxaffZ;gDEJ zOVRpR8K)sJko6#fTC_642>|0ijYAToixTva32gXZA;BQQZz2^Dmf$daZPMiUe?eSC zCW1iZLq6nm01uZ}|^WF(}L+%Kze zs7TXn3w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()7#oawGd7H(+$Db=1fKnb#Q#Z=LfeY4%V$OT1>HTKy-CExg%gY1kzJDquJ&2;kuO YALc!%>P*$1RsaA107*qoM6N<$f;u0iU;qFB literal 0 HcmV?d00001 diff --git a/beer/templates/beer.html b/beer/templates/beer.html index 207c63c..4f56f8a 100644 --- a/beer/templates/beer.html +++ b/beer/templates/beer.html @@ -44,8 +44,23 @@ })(); From 9694eb66b4cead14cded8b614a1beef32a65ce0e Mon Sep 17 00:00:00 2001 From: kleph Date: Thu, 9 Apr 2020 00:42:46 +0200 Subject: [PATCH 2/3] Add both favicons and routing Fix bad sed in Dockerfiles COPY --- Dockerfile | 2 +- beer/beer.py | 11 ++++++++++- beer/templates/beer.html | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) 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); From 18419989333acf1d204f0c96419bc3037069fdaa Mon Sep 17 00:00:00 2001 From: kleph Date: Thu, 9 Apr 2020 00:49:36 +0200 Subject: [PATCH 3/3] pylint --- beer/beer.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/beer/beer.py b/beer/beer.py index f8fe914..c7a11a1 100755 --- a/beer/beer.py +++ b/beer/beer.py @@ -27,18 +27,19 @@ def index(hours=None, minutes=None): return data @app.route('/favicon.ico') -def favicon(): +def default_favicon(): """ serve default favicon """ return send_from_directory('static', 'clock-icon.png') @app.route('/favicon/') -def favicon(): +def favicon(mode): """ serve the favicon according to the timer """ if mode == 'beer': - return send_from_directory('static', 'beer-icon.png') + filename = 'beer-icon.png' else: - return send_from_directory('static', 'clock-icon.png') + filename = 'clock-icon.png' + return send_from_directory('static', filename) def main(): """ main func """