The Real Python Community Members Map at https://members-map.realpython.com: a world map where members can add a pin for their city.
It's a small Flask app backed by Heroku Postgres. The map is drawn in the
browser with Leaflet (vendored in
members_map/static/vendor/) and
OpenStreetMap tiles.
New locations are geocoded with Nominatim through geopy.
You need uv and a PostgreSQL server.
$ uv sync
$ createdb members_map
$ export DATABASE_URL=postgresql://localhost/members_map
$ uv run flask --app members_map init-db
$ uv run flask --app members_map run --debugRun the tests and linters (the tests need a database they can wipe):
$ createdb members_map_test
$ uv run pytest # TEST_DATABASE_URL overrides the default URL
$ uv run ruff check . && uv run ruff format --check .| Variable | Purpose |
|---|---|
DATABASE_URL |
Postgres connection URL (set by Heroku Postgres) |
SECRET_KEY |
Signs the session cookie used for flash messages |
ADMIN_PASSWORD |
Enables the admin page at /admin/ (HTTP basic auth, any username): edit, delete and export pins. Unset means /admin/ returns 404 |
The app runs on Heroku (app members-map, heroku-26 stack). The Python
buildpack installs dependencies from uv.lock and reads the Python version
from .python-version. The release phase in the Procfile runs
init-db, which only creates the table if it's missing.
$ git push heroku master/admin/ lists every pin with flags for ones that look wrong: not in any
country (out at sea), duplicates of an older pin, and links in the location
or nickname. Filter by flag, select, and delete in bulk.
New pins store their country when they're added. To check older pins, run this once (it calls Nominatim about once per second, and can be stopped and rerun):
$ heroku run -a members-map flask --app members_map check-pinsPins are stored at one decimal place (about 11 km). The server rounds every
new pin, the "Use my current location" button rounds in the browser too, and
the release phase rounds any older pins (schema.sql). The explainer on the
map page describes this to members; keep it in sync if anything changes.
OpenStreetMap's tile servers require a valid Referer on every tile request.
The map is therefore rendered directly in the page served from our domain
(no data: URL iframes) and the app sends
Referrer-Policy: strict-origin-when-cross-origin. Keep it that way, or tiles
will be blocked again.