feat: add catalog

This commit is contained in:
2024-08-16 00:59:56 +03:00
parent aae8bc8649
commit b3043c3c8c
11 changed files with 91 additions and 22 deletions

View File

@@ -7,6 +7,7 @@ from fastapi.staticfiles import StaticFiles
from fastapi.templating import Jinja2Templates
from gallery.sketch.weather.api import WeatherApi
from gallery.sketch.weather.catalog import BUNDLE
from gallery.sketch.weather.mock import WEATHER_MOCK_DATA
from gallery.sketch.weather.model import WeatherResponse
from gallery.version import __version__
@@ -38,12 +39,13 @@ def mount(app: FastAPI):
async def get_weather_list(request: Request):
weather_api: WeatherApi = request.app.state.weather_api
locations = await weather_api.get_locations()
locations_data = BUNDLE.select_items(locations)
return templates.TemplateResponse(
request=request,
name="index.html",
context={
"version": __version__,
"locations": locations,
"locations": locations_data,
},
)

View File

@@ -29,7 +29,7 @@
</h3>
<ul class="app-list">
{% for location in locations %}
<li><a href="weather/{{location}}">{{location}}</a></li>
<li><a href="weather/{{location.id}}">{{location.name}}</a></li>
{% endfor %}
</ul>
</body>