#!/usr/bin/env python3 import argparse import re from datetime import datetime from pathlib import Path import bottle from bottle import request, run def latest_file(directory: Path) -> Path | None: files = [p for p in directory.glob("*.md") if re.match(r"^\d{14}\.md$", p.name)] return max(files, key=lambda p: p.stat().st_mtime) if files else None def save(directory: Path, text: str) -> Path: filename = f"{datetime.now():%Y%m%d%H%M%S}.md" path = directory / filename _ = path.write_text(text, encoding="utf-8") return path def make_page(directory: Path) -> str: latest = latest_file(directory) content = latest.read_text(encoding="utf-8") if latest else "" filename = latest.name if latest else "(none)" return f"""