This workshop example codes and template are available at watergis/terradraw-workshop-template
- Install dependencies
uv sync- Launch Zensical locally
uv run zensical serve- Format code with Ruff
uv run ruff format .uv run python scripts/generate_keys.py
uv run zensical buildSome live-editor examples (Mapbox GL JS, Google Maps) need API keys, which
are baked into the site at build time by scripts/generate_keys.py:
- Locally: copy
.env.exampleto.env, fill in the keys, and run the script before building/serving. It writes the gitignoreddocs/assets/live-editor/keys.js. - Cloudflare Pages: set
MAPBOX_ACCESS_TOKENandGOOGLE_MAPS_API_KEYas build environment variables in the Pages project settings, and use the build command above (the script prefers environment variables over.env).
Restrict the keys by HTTP referrer — the built site is public. If a key is missing, the affected example shows a notice instead of a map; everything else works.