This commit is contained in:
2026-04-15 11:37:56 +09:00
parent d6885f81f9
commit 4786512fca
2 changed files with 8 additions and 1 deletions
+7 -1
View File
@@ -101,6 +101,12 @@ async def default_response(request: Request, full_path: str) -> Response:
except PermissionError:
return error_page(templates, request, 403, "何をしてるんです?脆弱性報告のためならいいのですが、データ盗んで悪用するためなら今すぐにやめてくださいね?", "ディレクトリトラバーサルね、知ってる。公開してないところ覗きたいの?えっt")
if "curl" in request.headers.get("user-agent", "").lower():
markdown_mode = True
elif full_path.endswith(".md"):
markdown_mode = True
full_path = full_path[:-3] + ".html"
if full_path in ["", "/"]:
template_candidates = ["index.html"]
elif full_path.endswith(".html"):
@@ -110,7 +116,7 @@ async def default_response(request: Request, full_path: str) -> Response:
for name in template_candidates:
try:
if "curl" in request.headers.get("user-agent", "").lower():
if markdown_mode:
content = templates.env.get_template(name).render(request=request)
soup = BeautifulSoup(content, "html.parser")
main = str(soup.find("main")) if soup.find("main") else content