File tree Expand file tree Collapse file tree 2 files changed +12
-3
lines changed
Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change 22substitutions :
33 _SERVICE_NAME : pyplots-backend
44 _REGION : europe-west4
5- _MEMORY : 512Mi
5+ _MEMORY : 1Gi
66 _CPU : " 1"
77 _MIN_INSTANCES : " 1"
88 _MAX_INSTANCES : " 3"
5959 - " --set-env-vars=GOOGLE_CLOUD_PROJECT=$PROJECT_ID"
6060 - " --set-env-vars=GCS_BUCKET=pyplots-images"
6161 - " --no-cpu-throttling"
62+ - " --timeout=600"
6263 id : " deploy"
6364 waitFor : ["push-image"]
6465
Original file line number Diff line number Diff line change 11"""SEO endpoints (sitemap, bot-optimized pages)."""
22
33import html
4+ from datetime import datetime
45
56from fastapi import APIRouter , Depends , HTTPException , Request
67from fastapi .responses import HTMLResponse , Response
1415router = APIRouter (tags = ["seo" ])
1516
1617
18+ def _lastmod (dt : datetime | None ) -> str :
19+ """Format datetime as <lastmod> XML element, or empty string if None."""
20+ return f"<lastmod>{ dt .strftime ('%Y-%m-%d' )} </lastmod>" if dt else ""
21+
22+
1723# Minimal HTML template for social media bots (meta tags are what matters)
1824BOT_HTML_TEMPLATE = """<!DOCTYPE html>
1925<html lang="en">
@@ -83,11 +89,13 @@ async def get_sitemap(db: AsyncSession | None = Depends(optional_db)):
8389 if spec .impls : # Only include specs with implementations
8490 spec_id = html .escape (spec .id )
8591 # Overview page
86- xml_lines .append (f" <url><loc>https://pyplots.ai/{ spec_id } </loc></url>" )
92+ xml_lines .append (f" <url><loc>https://pyplots.ai/{ spec_id } </loc>{ _lastmod ( spec . updated ) } </url>" )
8793 # Individual implementation pages
8894 for impl in spec .impls :
8995 library_id = html .escape (impl .library_id )
90- xml_lines .append (f" <url><loc>https://pyplots.ai/{ spec_id } /{ library_id } </loc></url>" )
96+ xml_lines .append (
97+ f" <url><loc>https://pyplots.ai/{ spec_id } /{ library_id } </loc>{ _lastmod (impl .updated )} </url>"
98+ )
9199
92100 xml_lines .append ("</urlset>" )
93101 xml = "\n " .join (xml_lines )
You can’t perform that action at this time.
0 commit comments