about summary refs log tree commit diff
path: root/compose/cs/cs.py
blob: b455af2369fdda0bba2c8fb9cbfa6e68b279fa77 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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())