Send an anonymous message from a simple web page straight to a push notification on your phone, via ntfy.
This repo ships two interchangeable backends for the same frontend:
backend-python/— FastAPI + SQLite (good for a VPS, Docker, or local dev)backend-php/— plain PHP + SQLite (good for shared hosting / cPanel, no persistent process needed)
Pick whichever fits where you're hosting. Both expose the same two operations (POST a message, GET the message list) and both notify the same ntfy topic.
- Someone opens the page and types a message.
- The frontend sends it to the backend (
/messageon the Python API, ormessages.phpfor the PHP version). - The backend saves it to SQLite and forwards it to your ntfy topic.
- You get a push notification on your phone (via the ntfy app, subscribed to that topic).
- You can see the deployment on my website: TrustIT.ir/ping
.
├── frontend/ # static site — works with either backend
│ ├── index.html
│ ├── style.css
│ └── script.js
├── backend-python/ # FastAPI version
│ ├── main.py
│ ├── database.py
│ ├── models.py
│ ├── schemas.py
│ └── requirements.txt
└── backend-php/ # PHP version (for shared hosting)
└── messages.php
Requirements: Python 3.10+
cd backend-python
pip install -r requirements.txt
uvicorn main:app --reloadThe API runs at http://127.0.0.1:8000. Update script.js to point at that URL, and update the allow_origins list in main.py with wherever the frontend is served from.
Before running, set your own ntfy topic in main.py:
requests.post(
"https://ntfy.sh/YOUR_TOPIC_NAME",
data=data.message.encode("utf-8")
)Requirements: PHP with pdo_sqlite enabled. curl is used if available, otherwise it falls back to file_get_contents automatically.
-
Upload
backend-php/messages.phpand the contents offrontend/to the same folder on your host. -
Open
messages.phpand set your own values:$ntfyTopic = "YOUR_TOPIC_NAME"; define('ADMIN_KEY', 'CHANGE_THIS_TO_A_LONG_RANDOM_SECRET');
-
Make sure that folder is writable, so the SQLite file (
messages.db) can be created automatically on first request.
That's it — no build step, no process manager, just PHP.
| Setting | Where | Purpose |
|---|---|---|
| ntfy topic | main.py / messages.php |
Which ntfy topic receives the push notification. Pick something long and hard to guess — anyone who knows it can publish to it or subscribe to it. |
ADMIN_KEY |
messages.php only |
Required as ?key=... to view messages (GET). The Python version currently leaves GET /messages open — add auth there too if you expose it publicly. |
| Rate limit | messages.php only |
Defaults to 5 messages per IP per 10 minutes. Adjust RATE_LIMIT_MAX / RATE_LIMIT_WINDOW_SECONDS. |
- Don't commit your real ntfy topic or
ADMIN_KEYif the repo is public — anyone reading the source could read your messages or spam your phone. Consider moving them to environment variables / a gitignored config file before publishing. messages.dbis excluded via.gitignore— don't commit it, it contains real submitted messages.- The PHP version's
GETendpoint is gated byADMIN_KEY; make sure you actually change the default placeholder before deploying.
Install ntfy on your phone and subscribe to your topic to receive the push notifications.
MIT — do whatever you want with it.