diff --git a/.env b/.env-base similarity index 76% rename from .env rename to .env-base index 6b4bbc3..add7ab9 100644 --- a/.env +++ b/.env-base @@ -2,4 +2,6 @@ DOCKER_REPO=git.shmyga.ru DOCKER_GROUP=infernalgames DOCKER_ROOT="$DOCKER_REPO/$DOCKER_GROUP" VERSION=$(grep -m 1 'version' ./pyproject.toml | grep -oP 'version\s*=\s*"\K[^"]+') -DOCKER_PROJECTS=("gallery") \ No newline at end of file +DOCKER_PROJECTS=("gallery") + +OPENWEATHER_KEY="" \ No newline at end of file diff --git a/.gitignore b/.gitignore index e2a0b63..ea31b37 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ .venv #.vscode static/node_modules -static/dist \ No newline at end of file +static/dist +.env \ No newline at end of file diff --git a/gallery.code-workspace b/gallery.code-workspace index dc60536..458f5a2 100644 --- a/gallery.code-workspace +++ b/gallery.code-workspace @@ -8,6 +8,7 @@ "python.testing.pytestArgs": ["tests", "-s"], "python.testing.unittestEnabled": false, "python.testing.pytestEnabled": true, + "python.terminal.useEnvFile": true, "python-envs.pythonProjects": [ { "path": ".", diff --git a/gallery/easel/route/view/weather/__init__.py b/gallery/easel/route/view/weather/__init__.py index 7559cf5..3c4b6d9 100644 --- a/gallery/easel/route/view/weather/__init__.py +++ b/gallery/easel/route/view/weather/__init__.py @@ -50,7 +50,13 @@ def build_weather_response(request: AppRequest, response: WeatherResponse): router = APIRouter(prefix="/weather") -@router.get("/", response_class=HTMLResponse) +@router.get("/", response_class=RedirectResponse) +async def get_weather(request: AppRequest): + default_provider = request.app.state.api.get_api_providers(WeatherApi.TYPE)[0] + return RedirectResponse(default_provider) + + +@router.get("/{provider}", response_class=HTMLResponse) async def get_weather_index(request: AppRequest, weather_api: WeatherApiDepends, query: str | None = None): locations = (await weather_api.find_locations(query)) if query else [] return templates.TemplateResponse( @@ -62,12 +68,12 @@ async def get_weather_index(request: AppRequest, weather_api: WeatherApiDepends, ) -@router.get("/{location}", response_class=RedirectResponse) +@router.get("/{provider}/{location}", response_class=RedirectResponse) async def get_weather_default(location: str): return RedirectResponse(f"{location}/tag/today") -@router.get("/{location}/day/{date}", response_class=HTMLResponse) +@router.get("/{provider}/{location}/day/{date}", response_class=HTMLResponse) async def get_weather_day( request: AppRequest, weather_api: WeatherApiDepends, @@ -78,13 +84,13 @@ async def get_weather_day( return build_weather_response(request, response) -@router.get("/{location}/days/{days}", response_class=HTMLResponse) +@router.get("/{provider}/{location}/days/{days}", response_class=HTMLResponse) async def get_weather_days(request: AppRequest, weather_api: WeatherApiDepends, location: str, days: int): response = await weather_api.get_days(location, days) return build_weather_response(request, response) -@router.get("/{location}/tag/{tag}", response_class=HTMLResponse) +@router.get("/{provider}/{location}/tag/{tag}", response_class=HTMLResponse) async def get_weather_tag(request: AppRequest, weather_api: WeatherApiDepends, location: str, tag: str): tag_value = TagUtil.parse_tag(tag) if tag_value.type == TagType.DAY: diff --git a/gallery/easel/route/view/weather/templates/index.html b/gallery/easel/route/view/weather/templates/index.html index 0b07cc6..78d8044 100644 --- a/gallery/easel/route/view/weather/templates/index.html +++ b/gallery/easel/route/view/weather/templates/index.html @@ -36,7 +36,7 @@