Files
devplacepy/devplacepy/routers/seo.py
T
retoor 7fc9b0f715 chore: add retoor header to all devplacepy source files and update style agent header rule
The diff adds the mandatory `retoor <retoor@molodetz.nl>` header comment to every `.py` file under `devplacepy/` (including `__init__.py` and `routers/__init__.py`), and updates the `StyleAgent` in `agents/style.py` to instruct agents to only add the header on created or already-edited files rather than sweeping the entire repo. The `agents/base.py` operating protocol is also revised to reorder and clarify tool discipline rules.
2026-06-11 23:58:46 +00:00

44 lines
1.0 KiB
Python

# retoor <retoor@molodetz.nl>
import logging
from fastapi import APIRouter, Request
from fastapi.responses import PlainTextResponse, Response
from devplacepy.seo import make_sitemap, site_url
logger = logging.getLogger(__name__)
router = APIRouter()
@router.get("/robots.txt", response_class=PlainTextResponse)
async def robots_txt(request: Request):
base = site_url(request)
return PlainTextResponse(
f"""User-agent: *
Disallow: /auth/
Disallow: /messages/
Disallow: /notifications/
Disallow: /votes/
Disallow: /avatar/
Disallow: /follow/
Disallow: /admin/
Disallow: /uploads/
Disallow: /*?tab=
Disallow: /*?sort=
Allow: /static/
Sitemap: {base}/sitemap.xml
""",
headers={"Cache-Control": "public, max-age=3600"},
)
@router.get("/sitemap.xml")
async def sitemap_xml(request: Request):
base = site_url(request)
xml = make_sitemap(base)
return Response(
content=xml,
media_type="application/xml",
headers={"Cache-Control": "public, max-age=3600"},
)