feat: add catalog
This commit is contained in:
@@ -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,
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user