Skip to content

About

Real Python Community Members Map

Resources

Stars

5 stars

Watchers

3 watching

Forks

Latest commit

 

History

24 Commits

Folders and files

Repository files navigation

members-map

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.

Development

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 --debug

Run 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 .

Configuration

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

Deployment

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 and cleanup

/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-pins

Privacy

Pins 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.

Tile usage

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.

About

Real Python Community Members Map

Resources

Stars

5 stars

Watchers

3 watching

Forks

Releases

Packages

Contributors

Languages