blob: 4b1e0ba575db07cb5d0233cc17a13dba61275ec1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
import pathlib
import re
import bicephalus
from blog import blog_pages, page
def handler(request: bicephalus.Request) -> bicephalus.Response:
if request.path == "/":
return blog_pages.Root(request).response()
if re.match(r"/\d{4}/\d{2}/.*/", request.path):
blog_file = pathlib.Path("content") / (request.path[1:-1] + ".gmi")
if blog_file.exists():
return blog_pages.EntryPage(request, blog_file).response()
return page.NotFound(request).response()
|