A beginner-friendly Flask starter app that works in desktop and phone browsers.
cd hello-python-webapp
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
python app.pyOpen on computer:
Open on phone (same Wi-Fi):
- Find your Mac IP:
ipconfig getifaddr en0- Open
http://YOUR_IP:5001on your phone.
In this folder:
git init
git add .
git commit -m "Initial Flask web app with PWA support"
git branch -M main
git remote add origin YOUR_GITHUB_REPO_URL
git push -u origin main- Go to https://render.com and sign in with GitHub.
- Click New + -> Blueprint.
- Select your repository (
hello-python-webapp). - Render reads
render.yamland creates the service automatically. - Wait for deploy to finish, then open your Render URL.
After deployment, open your Render URL on phone:
- iPhone (Safari):
- Tap the Share button
- Tap Add to Home Screen
- Android (Chrome):
- Open browser menu
- Tap Install app or Add to Home screen
render.yaml- Render deployment configurationrequirements.txt- includesgunicornfor production serverstatic/manifest.webmanifest- PWA app metadatastatic/sw.js- service worker (basic offline caching)static/main.js- registers service workerstatic/icons/icon.svg- app icondb.py- Uses SQLite locally (hello_app.db, gitignored) and PostgreSQL on Render whenDATABASE_URLis setrender.yaml- Provisions a free Render PostgreSQL database and injectsDATABASE_URLinto the web service/login+/admin- Simple admin login (password) and admin page to delete/clear greetings
Local vs production: With no DATABASE_URL, the app uses SQLite. On Render, DATABASE_URL points at Postgres so greetings persist across deploys and restarts.
Your Blueprint now defines:
SECRET_KEY: auto-generated (required for sessions)ADMIN_PASSWORD: you set this in Render (required to log in)
After you push these changes, go to Render → your web service → Environment and set ADMIN_PASSWORD to something strong, then redeploy.
- Commit and push the updated
render.yamlandrequirements.txt. - In the Render dashboard, open your Blueprint and click Manual sync / Apply (wording varies) so Render creates the
hello-dbdatabase and wiresDATABASE_URL. - Wait for the web service to redeploy.
If you already had a web service without a database, the sync may add Postgres and set the env var automatically. If anything fails, open your web service → Environment → confirm DATABASE_URL exists (from the linked Postgres instance).
Set DATABASE_URL to your database URL before python app.py (e.g. from Render’s External Database URL in the database dashboard, or a local Docker Postgres). The app will use Postgres whenever DATABASE_URL is set.
app.py- Flask app routes and logicdb.py- SQLite (local) or PostgreSQL (DATABASE_URL) setup and queriestemplates/index.html- UI templatestatic/style.css- app styling
