Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

💬 Ping — Anonymous Message Box

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.

How it works

  1. Someone opens the page and types a message.
  2. The frontend sends it to the backend (/message on the Python API, or messages.php for the PHP version).
  3. The backend saves it to SQLite and forwards it to your ntfy topic.
  4. You get a push notification on your phone (via the ntfy app, subscribed to that topic).
  5. You can see the deployment on my website: TrustIT.ir/ping

Project structure

.
├── 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

Option A — Python (FastAPI)

Requirements: Python 3.10+

cd backend-python
pip install -r requirements.txt
uvicorn main:app --reload

The 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")
)

Option B — PHP (shared hosting / cPanel)

Requirements: PHP with pdo_sqlite enabled. curl is used if available, otherwise it falls back to file_get_contents automatically.

  1. Upload backend-php/messages.php and the contents of frontend/ to the same folder on your host.

  2. Open messages.php and set your own values:

    $ntfyTopic = "YOUR_TOPIC_NAME";
    define('ADMIN_KEY', 'CHANGE_THIS_TO_A_LONG_RANDOM_SECRET');
  3. 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.

Configuration reference

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.

Security notes

  • Don't commit your real ntfy topic or ADMIN_KEY if 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.db is excluded via .gitignore — don't commit it, it contains real submitted messages.
  • The PHP version's GET endpoint is gated by ADMIN_KEY; make sure you actually change the default placeholder before deploying.

Notifications app

Install ntfy on your phone and subscribe to your topic to receive the push notifications.

License

MIT — do whatever you want with it.

About

Send an anonymous message from a simple web page straight to a push notification on your phone, via ntfy.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages