From 314c42acd1595146a66a9530c982b660832cf3e5 Mon Sep 17 00:00:00 2001 From: Paweł Dybiec Date: Sun, 24 May 2020 23:36:36 +0200 Subject: Add cs map service --- compose/app/Dockerfile | 2 +- compose/cs/Dockerfile | 6 ++++++ compose/cs/__pycache__/cs.cpython-38.pyc | Bin 0 -> 1474 bytes compose/cs/cs.py | 30 ++++++++++++++++++++++++++ compose/cs/requirements.txt | 1 + compose/cs/static/icon.png | Bin 0 -> 3734 bytes compose/cs/static/style.css | 35 +++++++++++++++++++++++++++++++ compose/cs/templates/main.html | 27 ++++++++++++++++++++++++ 8 files changed, 100 insertions(+), 1 deletion(-) create mode 100644 compose/cs/Dockerfile create mode 100644 compose/cs/__pycache__/cs.cpython-38.pyc create mode 100644 compose/cs/cs.py create mode 100644 compose/cs/requirements.txt create mode 100644 compose/cs/static/icon.png create mode 100644 compose/cs/static/style.css create mode 100644 compose/cs/templates/main.html (limited to 'compose') diff --git a/compose/app/Dockerfile b/compose/app/Dockerfile index 8e67d74..8db20e0 100644 --- a/compose/app/Dockerfile +++ b/compose/app/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.4-alpine +FROM python:3.8-alpine ADD . /code WORKDIR /code RUN pip install -r requirements.txt diff --git a/compose/cs/Dockerfile b/compose/cs/Dockerfile new file mode 100644 index 0000000..57323dd --- /dev/null +++ b/compose/cs/Dockerfile @@ -0,0 +1,6 @@ +FROM python:3.7-alpine +ADD . /code +WORKDIR /code +RUN pip install -r requirements.txt +ENV FLASK_APP cs.py +CMD ["python3", "-m", "flask", "run", "--host=0.0.0.0"] diff --git a/compose/cs/__pycache__/cs.cpython-38.pyc b/compose/cs/__pycache__/cs.cpython-38.pyc new file mode 100644 index 0000000..9d63e21 Binary files /dev/null and b/compose/cs/__pycache__/cs.cpython-38.pyc differ diff --git a/compose/cs/cs.py b/compose/cs/cs.py new file mode 100644 index 0000000..b455af2 --- /dev/null +++ b/compose/cs/cs.py @@ -0,0 +1,30 @@ +import datetime +from typing import List, Tuple +from flask import Flask, render_template +app = Flask("Today's maps") +maps = [ "mirage 🇲🇦", + "inferno 🔥", + "overpass 🌉", + "vertigo 🏗️", + "nuke ☢", + "train 🚆", + "dust 🏜", + "anubis ☥", + "cache ☭", + "agency 🏢", + "office 🖥"] + +def maps_of_day(day: datetime.date) -> Tuple[str, str]: + l = len(maps) + i = (day-day.replace(day=1, month=1)).days+1 + return maps[(2*i)%l], maps[(2*i+1)%l] + +def maps_of_current_week() -> List[Tuple[str, str, str]]: + today = datetime.date.today() + days = [today+datetime.timedelta(days=i) for i in range(6)] + return [(day.strftime("%A"), *maps_of_day(day)) for day in days] + +@app.route("/") +def main(): + return render_template("main.html", maps=maps_of_current_week()) + diff --git a/compose/cs/requirements.txt b/compose/cs/requirements.txt new file mode 100644 index 0000000..7e10602 --- /dev/null +++ b/compose/cs/requirements.txt @@ -0,0 +1 @@ +flask diff --git a/compose/cs/static/icon.png b/compose/cs/static/icon.png new file mode 100644 index 0000000..b02d809 Binary files /dev/null and b/compose/cs/static/icon.png differ diff --git a/compose/cs/static/style.css b/compose/cs/static/style.css new file mode 100644 index 0000000..b4eac13 --- /dev/null +++ b/compose/cs/static/style.css @@ -0,0 +1,35 @@ +@import url("https://fonts.googleapis.com/css?family=Noto+Sans"); +html { + font-family: "Noto Sans", "Noto Color Emoji"; +} +html table { + font-size: 30px; + width: 40%; + margin: 0 auto; + border-collapse: collapse; + margin-bottom: 5mm; +} +html table th { + border-bottom: .2mm solid #5b5; + color: #5b5; + padding: 2mm; + text-transform: uppercase; +} +html table td { + padding: 2.5mm; +} +.map { + color: #55b; + font-weight: bold; + text-align: center; +} +.maps th:first-of-type, +.maps td:first-of-type { + text-align: left; + padding-left: 3mm; +} +.maps th:last-of-type, +.maps td:last-of-type { + text-align: right; + padding-right: 3mm; +} diff --git a/compose/cs/templates/main.html b/compose/cs/templates/main.html new file mode 100644 index 0000000..c93bfac --- /dev/null +++ b/compose/cs/templates/main.html @@ -0,0 +1,27 @@ + + + Map of a day + + + + + + + + + + + + {% for e in maps %} + + + + + + + {% endfor %} + +
Day Map Map
{{ e[0] }}{{ e[1] }}{{ e[2] }}
+ + + -- cgit 1.4.1