From 4786512fca0612759a1002857e2c41e97feaad38 Mon Sep 17 00:00:00 2001 From: nercone-dev Date: Wed, 15 Apr 2026 11:37:56 +0900 Subject: [PATCH] -- --- public/base.html | 1 + src/nercone_website/server.py | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/public/base.html b/public/base.html index c2772d1..171c723 100644 --- a/public/base.html +++ b/public/base.html @@ -1,3 +1,4 @@ + diff --git a/src/nercone_website/server.py b/src/nercone_website/server.py index 5a0a503..cf7ae04 100644 --- a/src/nercone_website/server.py +++ b/src/nercone_website/server.py @@ -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