63 lines
1.7 KiB
Python
63 lines
1.7 KiB
Python
import inject
|
|
from litestar import (
|
|
Controller,
|
|
get,
|
|
MediaType,
|
|
)
|
|
|
|
from server.modules.descriptions import CharactersService, Breed
|
|
|
|
|
|
class SeoController(Controller):
|
|
@get("/sitemap.xml", media_type=MediaType.XML)
|
|
async def sitemaps(self) -> bytes:
|
|
characters_service: CharactersService = inject.instance(CharactersService)
|
|
breeds: list[Breed] = await characters_service.get_characters()
|
|
lastmod = "2025-10-04T19:01:03+00:00"
|
|
beers_url = ""
|
|
for b in breeds:
|
|
beers_url += f"""
|
|
<url>
|
|
<loc>https://xn-----6kcp3cadbabfh8a0a.xn--p1ai/dogs-characteristics/{b.alias}</loc>
|
|
<lastmod>{lastmod}</lastmod>
|
|
</url>
|
|
"""
|
|
return f"""<?xml version="1.0" encoding="UTF-8"?>
|
|
<urlset
|
|
xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
|
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9
|
|
http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
|
|
<!-- created with Free Online Sitemap Generator www.xml-sitemaps.com -->
|
|
|
|
|
|
<url>
|
|
<loc>https://xn-----6kcp3cadbabfh8a0a.xn--p1ai/</loc>
|
|
<lastmod>{lastmod}</lastmod>
|
|
</url>
|
|
<url>
|
|
<loc>https://xn-----6kcp3cadbabfh8a0a.xn--p1ai/cats</loc>
|
|
<lastmod>{lastmod}</lastmod>
|
|
</url>
|
|
<url>
|
|
<loc>https://xn-----6kcp3cadbabfh8a0a.xn--p1ai/donate</loc>
|
|
<lastmod>{lastmod}</lastmod>
|
|
</url>
|
|
<url>
|
|
<loc>https://xn-----6kcp3cadbabfh8a0a.xn--p1ai/dogs-characteristics</loc>
|
|
<lastmod>{lastmod}</lastmod>
|
|
</url>
|
|
{beers_url}
|
|
|
|
</urlset>
|
|
""".encode()
|
|
|
|
@get("/robots.txt", media_type=MediaType.TEXT)
|
|
async def robots(self) -> str:
|
|
return """
|
|
User-agent: *
|
|
Allow: /
|
|
|
|
Sitemap: https://xn-----6kcp3cadbabfh8a0a.xn--p1ai/sitemap.xml
|
|
"""
|