A self-hosted web push notification demo server for testing and training purposes. Built with FastAPI and vanilla JavaScript.
- Web Push Notifications - Full VAPID-based push notification system
- Client Management - Track registered browsers with detailed device info
- Custom Templates - Create notification templates with OS-specific icons and themes
- Scheduled Notifications - Queue notifications to send at specific times
- Notification History - Log of all sent notifications with delivery stats
- Export Data - Download client list as CSV or JSON
- Webhook Support - HTTP POST on new client registration
- SSL/TLS Support - Manual certs or automatic Let's Encrypt via certbot
- Password Protected - Admin pages secured with HTTP Basic Auth
- Python 3.8+
- pip
# Clone the repository
git clone https://github.com/yourusername/push_demo.git
cd push_demo
# Install dependencies
pip install fastapi uvicorn pywebpush cryptography jinja2 python-multipart httpx
# Run the server
python server.pyThe server will start at http://localhost:8000. Login credentials are displayed in the terminal.
| Route | Description |
|---|---|
/ |
Public registration page |
/register |
Detailed registration with device info |
/dashboard |
Send notifications, view clients |
/templates |
Create/manage notification templates |
/debug |
Debug tools and subscription info |
/admin |
Server configuration |
Visit http://localhost:8000/ and click Register. Grant notification permission when prompted.
Go to /dashboard, fill in the notification details, and click Send push.
Visit /templates to create reusable notification templates with:
- OS-specific icons (Windows, macOS, Linux, Android, iOS)
- Custom colors and appearance
- Require interaction / silent options
Configuration is stored in config.json:
{
"admin_password": "your-password",
"ssl_enabled": false,
"domain": "",
"webhook_url": "",
"redirect_url": ""
}With Let's Encrypt:
sudo python server.py --domain push.example.com --email admin@example.comWith manual certificates:
python server.py --ssl --ssl-cert /path/to/cert.pem --ssl-key /path/to/key.pemPOST /api/send- Send notification (form data)POST /api/schedule- Schedule a notificationGET /api/scheduled- List scheduled notificationsGET /api/history- Get notification history
GET /api/clients- List all clientsDELETE /api/clients/{id}- Delete a clientGET /api/export/clients?format=json|csv- Export clients
GET /api/templates- List templatesPOST /api/templates- Create templatePUT /api/templates/{id}- Update templateDELETE /api/templates/{id}- Delete template
GET /api/admin/config- Get configurationPOST /api/admin/config- Update configurationPOST /api/admin/password- Change password
push_demo/
├── server.py # FastAPI application
├── sw.js # Service worker for push handling
├── config.json # Configuration (auto-generated)
├── push_demo.db # SQLite database (auto-generated)
├── vapid_private.pem # VAPID private key (auto-generated)
├── vapid_public.pem # VAPID public key (auto-generated)
└── templates/
├── index.html # Public registration
├── register.html # Detailed registration
├── dashboard.html # Admin dashboard
├── templates.html # Template management
├── debug.html # Debug tools
└── admin.html # Server settings
- All push notifications are encrypted in transit (RFC 8291 - ECDH + AES-128-GCM)
- VAPID keys are auto-generated on first run
- Admin password is randomly generated and saved to
config.json - The public registration page (
/) does not require authentication
MIT License - See LICENSE for details.