From 0c659db6cbcb3fdfd1115f71e40ba0e8a19beb75 Mon Sep 17 00:00:00 2001 From: Davide Scaini Date: Mon, 20 Apr 2026 21:17:03 +0200 Subject: [PATCH] fix: default DEM URL to api.open-elevation.com No configuration needed out of the box; --dem-url only required to override the default with a self-hosted or alternative endpoint. --- bincio/edit/cli.py | 7 ++----- bincio/edit/server.py | 8 ++------ bincio/serve/cli.py | 5 ++--- bincio/serve/server.py | 8 ++------ 4 files changed, 8 insertions(+), 20 deletions(-) diff --git a/bincio/edit/cli.py b/bincio/edit/cli.py index 8aec131..f28e615 100644 --- a/bincio/edit/cli.py +++ b/bincio/edit/cli.py @@ -25,7 +25,7 @@ console = Console() @click.option("--strava-client-secret", default=None, envvar="STRAVA_CLIENT_SECRET", help="Strava API client secret. Also reads STRAVA_CLIENT_SECRET env var.") @click.option("--dem-url", default=None, envvar="DEM_URL", - help="Base URL of an Open-Elevation-compatible API (enables 'Recalculate elevation' button).") + help="Base URL of an Open-Elevation-compatible API (default: https://api.open-elevation.com).") def edit( data_dir: Optional[str], port: int, @@ -78,10 +78,7 @@ def edit( console.print(f"Strava sync: [green]enabled[/green] (client {strava_client_id})") else: console.print("Strava sync: [yellow]disabled[/yellow] (pass --strava-client-id to enable)") - if dem_url: - console.print(f"DEM: [green]enabled[/green] ({dem_url})") - else: - console.print("DEM: [yellow]disabled[/yellow] (pass --dem-url to enable elevation recalculation)") + console.print(f"DEM: [cyan]{srv.dem_url}[/cyan]") uvicorn.run(srv.app, host="127.0.0.1", port=port, log_level="warning") diff --git a/bincio/edit/server.py b/bincio/edit/server.py index 648a4a3..f06a8b4 100644 --- a/bincio/edit/server.py +++ b/bincio/edit/server.py @@ -20,7 +20,7 @@ data_dir: Path | None = None site_url: str = "http://localhost:4321" strava_client_id: str = "" strava_client_secret: str = "" -dem_url: str = "" # Open-Elevation-compatible API base URL; empty = feature disabled +dem_url: str = "https://api.open-elevation.com" # Open-Elevation-compatible API base URL # In-memory CSRF state tokens for OAuth flows (token → True); cleared after use _oauth_states: set[str] = set() @@ -435,11 +435,7 @@ async def recalculate_elevation_endpoint(activity_id: str) -> JSONResponse: Requires --dem-url to be set when starting bincio edit. """ if not dem_url: - raise HTTPException( - 503, - "DEM URL not configured. " - "Pass --dem-url to bincio edit (e.g. https://api.open-elevation.com).", - ) + raise HTTPException(503, "DEM URL not configured.") dd = _get_data_dir() _check_id(activity_id) try: diff --git a/bincio/serve/cli.py b/bincio/serve/cli.py index 2cbf9f6..478cc1b 100644 --- a/bincio/serve/cli.py +++ b/bincio/serve/cli.py @@ -21,7 +21,7 @@ console = Console() @click.option("--max-users", default=None, type=int, help="Override max users for this instance (0 = unlimited; updates the DB setting)") @click.option("--public-url", default=None, envvar="PUBLIC_URL", help="Public base URL (e.g. https://yourdomain.com). Required for Strava OAuth to work behind a reverse proxy.") @click.option("--webroot", default=None, type=click.Path(), help="Nginx webroot (e.g. /var/www/bincio). When set, uploads trigger a full Astro build + rsync so new activity pages are immediately accessible without a git push.") -@click.option("--dem-url", default=None, envvar="DEM_URL", help="Base URL of an Open-Elevation-compatible API (enables 'Recalculate elevation' button in the edit drawer).") +@click.option("--dem-url", default=None, envvar="DEM_URL", help="Base URL of an Open-Elevation-compatible API (default: https://api.open-elevation.com).") def serve(data_dir: str, site_dir: Optional[str], host: str, port: int, strava_client_id: Optional[str], strava_client_secret: Optional[str], max_users: Optional[int], public_url: Optional[str], @@ -77,8 +77,7 @@ def serve(data_dir: str, site_dir: Optional[str], host: str, port: int, console.print(f" Users: [yellow]max {current_limit}[/yellow]") else: console.print(f" Users: [dim]unlimited[/dim]") - if dem_url: - console.print(f" DEM: [cyan]{dem_url}[/cyan]") + console.print(f" DEM: [cyan]{srv.dem_url}[/cyan]") console.print() log_config = uvicorn.config.LOGGING_CONFIG.copy() diff --git a/bincio/serve/server.py b/bincio/serve/server.py index 5b57f4d..8e558fe 100644 --- a/bincio/serve/server.py +++ b/bincio/serve/server.py @@ -158,7 +158,7 @@ webroot: Path | None = None # nginx webroot — when set, trigger full rebuil strava_client_id: str = "" strava_client_secret: str = "" public_url: str = "" # e.g. "https://yourdomain.com" — used for OAuth redirect URIs -dem_url: str = "" # Open-Elevation-compatible API base URL; empty = feature disabled +dem_url: str = "https://api.open-elevation.com" # Open-Elevation-compatible API base URL _db = None # sqlite3.Connection, opened lazily @@ -1279,11 +1279,7 @@ async def recalculate_elevation_endpoint( user = _require_user(bincio_session) _check_id(activity_id) if not dem_url: - raise HTTPException( - 503, - "DEM URL not configured. " - "Pass --dem-url to bincio serve (e.g. https://api.open-elevation.com).", - ) + raise HTTPException(503, "DEM URL not configured.") dd = _get_data_dir() / user.handle if not (dd / "activities" / f"{activity_id}.json").exists(): raise HTTPException(404, "Activity not found")