Spaces:
Paused
Paused
Upload entrypoint.sh with huggingface_hub
Browse files12345678910111213141516171819202122232425262728293031323334#!/bin/sh# Build config.json at runtime from env (HF Secrets), then start server.set -e
python - <<'PY'import json, os
cfg = json.load(open("/app/config.example.json"))
# API keys from HF Secret API_KEYS (comma-separated). Empty -> no auth.keys = [k.strip() for k in os.environ.get("API_KEYS", "").split(",") if k.strip()]cfg["api_keys"] = keys
# HF Spaces serves on app_port (default 7860).cfg["port"] = int(os.environ.get("PORT", "7860"))cfg["host"] = "0.0.0.0"
# Optional cookie for real Pro routing, via secret GEMINI_COOKIE.cookie = os.environ.get("GEMINI_COOKIE", "").strip()if cookie: with open("/app/cookie.txt", "w") as f: f.write(cookie) cfg["cookie_file"] = "/app/cookie.txt"
# Optional outbound proxy.proxy = os.environ.get("PROXY", "").strip()if proxy: cfg["proxy"] = proxy
json.dump(cfg, open("/app/config.json", "w"))print(f"config built: port={cfg['port']} auth={'on' if keys else 'off'} cookie={'yes' if cookie else 'no'}")PY
exec python -m gemini_web2api --config /app/config.jsonentrypoint.shAdded+34