Tharindu96/Views_dashboard
0
ArcGIS Online Item Statistics Dashboard
Tracks total views since launch and last 7-day views for all ArcGIS Online items across 4 categories: Basin, Country, Region, Continent.
Setup
1. Files needed in the same folder
app.py
fetch_stats.py
requirements.txt
items.csv
credentials.json ← fill in your credentials
data/ ← auto-created when you run fetch_stats.py2. Fill in credentials.json
{
"username": "your-arcgis-username",
"password": "your-arcgis-password",
"portal": "https://www.arcgis.com"
}3. Run locally first (to test)
pip install -r requirements.txt
python fetch_stats.py # pulls stats from ArcGIS, saves to data/stats.json
python app.py # launches dashboard at http://localhost:78604. Deploy to Hugging Face Spaces
Option A — Using Space Secrets (recommended, keeps password safe):
- Add these in your Space → Settings → Variables and Secrets:
ARCGIS_USERNAME= your usernameARCGIS_PASSWORD= your passwordARCGIS_PORTAL= https://www.arcgis.com- Delete credentials.json before pushing
Option B — Include credentials.json (private Space only):
- Set Space visibility to Private
- Include credentials.json in your push
git clone https://huggingface.co/spaces/YOUR_USERNAME/arcgis-dashboard
cp app.py fetch_stats.py requirements.txt items.csv credentials.json <cloned-folder>/
cp -r data/ <cloned-folder>/data/ # include pre-fetched stats
cd <cloned-folder>
git add .
git commit -m "initial deploy"
git pushHow it works
- Fetch Latest Stats button → runs
fetch_stats.py→ pulls live data from ArcGIS Online API - Reload from Saved Data → reads
data/stats.jsonwithout calling ArcGIS (instant) - Charts auto-load on page open using the last saved stats
Items tracked
22 items across 4 categories:
- 🔵 Basin (10): Volta, Zambezi, Limpopo, Mara, Incomati, Rift Valley, Lake Tana, Souss Massa, Maputo River, Upper Niger
- 🟠 Country (5): Zambia, Kenya, Ghana, Burkina Faso, Ethiopia
- 🟢 Region (6): Madagascar, Northern, Central, Eastern, Western, Southern
- 🟣 Continent (1): Continent Africa
