How I Control My Android Phone From a Cloud Server Using 100 Lines of Flask

Published: (April 24, 2026 at 04:29 AM EDT)
2 min read
Source: Dev.to

Source: Dev.to

The Problem

Most cross‑device automation forces you to choose between:

  • Too simple: hard‑coded cron jobs with no coordination
  • Too complex: Redis, RabbitMQ, Firebase — full infrastructure for a simple notification

I just wanted my cloud script to say “hey, buzz my phone.” That’s it.

How It Works

Intent Bus is a tiny Flask app backed by SQLite. It has one job: let scripts post work, and let workers claim and execute that work.

Step 1 — Cloud script posts an intent

curl -X POST https://your-bus.pythonanywhere.com/intent \
  -H "Content-Type: application/json" \
  -H "X-API-Key: your_key_here" \
  -d '{"goal":"send_notification","payload":{"message":"Scrape complete"}}'

Step 2 — Termux worker claims it

A bash script running on the phone polls the bus every 10 seconds. When it sees a job, it claims it with an atomic lock, executes it, and marks it fulfilled.

Step 3 — Phone buzzes

termux-notification --title "System Update" --content "$MESSAGE"

That’s the entire flow.

What Makes It Reliable

  1. Atomic locking – SQLite’s UPDATE with a row‑count check ensures only one worker ever claims a job, even with multiple workers running simultaneously.
  2. Visibility timeout – If a worker crashes mid‑job, the lock expires after 60 seconds and the job returns to the queue automatically.
  3. Topic routing – Workers only claim jobs matching their goal via ?goal=. A notification worker never accidentally picks up a logging job.

The Architecture

Cloud Scraper (PythonAnywhere)
        |
        | POST /intent

Intent Bus (Flask + SQLite)
        |
        | claim + fulfill

Termux Worker (Android Phone)
        |
        | termux-notification

📱 Phone Notification

What It Can Do

Because the bus is just HTTP, any script anywhere can post or claim jobs:

  • Scraper finishes → notify phone
  • Website goes down → alert Discord
  • GitHub push → trigger deploy on a home Raspberry Pi behind a firewall
  • Old Android phone → free Twilio replacement via termux-sms-send

Security

After posting this publicly, people immediately stress‑tested the open endpoint. I added API‑key authentication — the key is stored in PythonAnywhere’s WSGI environment, never in the repo. Workers read the key from a local .apikey file.

Try It

The full code, spec, and examples are on GitHub:

https://github.com/dsecurity49/Intent-Bus

It runs free on PythonAnywhere + any Android phone with Termux. No Docker, no dependencies beyond Flask.

If you build a worker script for it, PRs are welcome.

0 views
Back to Blog

Related posts

Read more »