| --- |
| title: Pinger |
| emoji: ๐ |
| colorFrom: green |
| colorTo: blue |
| sdk: docker |
| app_port: 7860 |
| --- |
| # HuggingFace Spaces Pinger |
|
|
| A simple service that pings your HuggingFace Spaces to prevent them from going to sleep after 24 hours of inactivity. |
|
|
| ## Features |
|
|
| - Pings configured HuggingFace Spaces at regular intervals |
| - Simple status dashboard at `/` |
| - Health check endpoint at `/health` |
| - Configurable ping interval |
|
|
| ## Setup |
|
|
| ### Environment Variables |
|
|
| | Variable | Description | Default | |
| |----------|-------------|---------| |
| | `SPACES_URLS` | Comma-separated list of HF Space URLs to ping | (required) | |
| | `PING_INTERVAL_SECONDS` | Seconds between each ping cycle | `3600` | |
| | `HF_TOKEN` | HuggingFace token for private spaces | (optional) | |
|
|
| ### Example |
|
|
| ```bash |
| export SPACES_URLS="https://user-name-space1.hf.space,https://user-name-space2.hf.space" |
| python main.py |
| ``` |
|
|
| ## Deploy to HuggingFace Spaces |
|
|
| 1. Create a new Space on [HuggingFace](https://huggingface.co/new-space) |
| 2. Select **Docker** as the SDK |
| 3. Clone your space repo |
| 4. Copy these files: |
| - `main.py` |
| - `requirements.txt` |
| - `Dockerfile` |
| 5. Add the `SPACES_URLS` environment variable in your Space settings |
| 6. Push and wait for deployment |
|
|
| ## Local Development |
|
|
| ```bash |
| pip install -r requirements.txt |
| export SPACES_URLS="https://xxx.hf.space,https://yyy.hf.space" |
| python main.py |
| ``` |
|
|
| ## Endpoints |
|
|
| - `GET /` - Status dashboard showing all spaces and last ping results |
| - `GET /health` - Health check (returns `{"status": "healthy"}`) |
|
|