~sircmpwn/cgi-scripts

c0cd51be0f51545937e793b19b84e506ec843988 — Drew DeVault 4 years ago 18fb8e2
Do expiry better anyway
1 files changed, 3 insertions(+), 3 deletions(-)

M hn.py
M hn.py => hn.py +3 -3
@@ 20,8 20,8 @@ if not path or path == "/":

    posts = None
    if cache:
        date = datetime.fromtimestamp(cache["date"])
        if date < datetime.now() - timedelta(seconds=300):
        expiry = datetime.fromtimestamp(cache["expiry"])
        if datetime.now() < expiry:
            posts = cache["posts"]

    if not posts:


@@ 34,7 34,7 @@ if not path or path == "/":
        with open("/tmp/post-cache.json", "w") as f:
            f.write(json.dumps({
                "posts": posts,
                "date": datetime.timestamp(datetime.now()),
                "expiry": datetime.timestamp(datetime.now() + timedelta(seconds=300)),
            }))

    sys.stdout.write("20 text/gemini\r\n")