W16: Putting It Online

Selling at a market, you have three choices. Leave a stack of free leaflets on a public table: no one needs to stand there. Open your own front door and sell from home: free, but only while you are home. Or rent a stall in a covered market that is open every day: it costs rent, but it never closes. Putting your app online is the same choice. Pi Workbench's plan picks one way for each situation, so you do not have to compare twenty hosting companies.

Which Way?

flowchart TD Q{Does the app have a server?
W14's one question} Q -->|No| P[GitHub Pages
free] Q -->|Yes| A{Must it be up
when your computer is off?} A -->|No| F[Tailscale Funnel
free, from your computer] A -->|Yes| Y[Fly.io
paid, always on]

T44: Putting a Server Online compares the options in more depth, including a rented server (VPS) with Caddy. This lesson follows the plan's three.

Prices and free tiers change often. Everything below was true when this lesson was written; check each provider's own page before you rely on it.

1. GitHub Pages: Apps with No Server

An app with no server (W14) is just files. GitHub Pages hosts files for free:

  1. Push the project to a public repository on GitHub (W12).
  2. On the repository page: Settings → Pages, Source Deploy from a branch, branch main, folder / (root). Save.
  3. After a minute or two, open https://YOUR-NAME.github.io/REPOSITORY/.

From then on, git push publishes. A18 walks through exactly this.

Pages cannot run Python, keep a SQLite file, or hide a secret. For that, read on.

2. Tailscale Funnel: the Free Default for Server Apps

Your app keeps running on your own computer, with its SQLite file right there, and Tailscale Funnel gives it a public HTTPS address anyone can open.

You already use Tailscale for the phone (W13); serve shares with your own devices, funnel shares with everyone. With your app running on port 8000:

tailscale funnel 8000

Tailscale prints an address like https://my-laptop.your-tailnet.ts.net. The first time, it may ask you to enable HTTPS and Funnel for your network, with a link. It lasts while the command runs.

If the workbench's phone access already uses that main address, put your app on another port. Funnel allows only 443, 8443 and 10000:

tailscale funnel --https=8443 localhost:8000

Run the app without --reload when others use it, so a half-saved edit does not restart it under them:

uv run uvicorn app.main:app --port 8000

Pi Workbench will do this step for you soon: a "share publicly" recipe that starts the app and the Funnel and tells you the address.

3. Fly.io: Always On

When the app must be up while your computer is off, it needs a computer that is always on. The plan's choice is Fly.io, a platform that runs your app in a data centre.

The steps today are in Fly.io's own documentation for Python apps: install their fly command, fly launch in your project, create a volume, and fly deploy. Ask Pi to prepare the project for it, and read every change.

Pi Workbench will do this step for you soon: a Fly.io recipe with the volume for SQLite, migrations on deploy and backups set up.

Checked and left out by the plan: platforms whose free tier sleeps and wipes the disk on deploy (SQLite is lost), and hosts that run only Node.js or static files.

What Changes in Production

"Production" is the real copy other people use. T44's last section is required reading. The short version:

This Week's Exercise

  1. For each app on your list from W14, choose: Pages, Funnel or Fly.io. Write why in one line.
  2. Publish your no-server app on GitHub Pages, if you have not.
  3. Share your notes app with tailscale funnel 8000, open it on a phone using mobile data (not your Wi-Fi), then stop it with Ctrl+C.
  4. Read T44's "What Changes in Production".

Key Takeaways

  • No server: GitHub Pages, free, git push publishes
  • A server app: Tailscale Funnel is the free default; the app and its SQLite file stay on your computer, which must stay on
  • Always on: Fly.io, paid (a few dollars a month), with a volume so SQLite survives deploys
  • Funnel allows ports 443, 8443 and 10000; its bandwidth is limited
  • Prices and free tiers change: check before you rely on them. In production: secrets in the environment, HTTPS, backups, logs