Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: CI

on:
push:
branches: [master]
pull_request:

jobs:
test:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:17
env:
POSTGRES_PASSWORD: postgres
POSTGRES_DB: members_map_test
ports: ["5432:5432"]
options: >-
--health-cmd pg_isready --health-interval 5s
--health-timeout 5s --health-retries 10
env:
TEST_DATABASE_URL: postgresql://postgres:postgres@localhost/members_map_test
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v6
- run: uv sync --locked
- run: uv run ruff check .
- run: uv run ruff format --check .
- run: uv run pytest
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ target/
.ipynb_checkpoints

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule
Expand Down
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.14
3 changes: 2 additions & 1 deletion Procfile
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
web: gunicorn main:app
web: gunicorn 'members_map:create_app()'
release: flask --app members_map init-db
1 change: 0 additions & 1 deletion Procfile.windows

This file was deleted.

57 changes: 56 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,57 @@
# members-map
Real Python Community 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](https://leafletjs.com) (vendored in
`members_map/static/vendor/`) and
[OpenStreetMap tiles](https://operations.osmfoundation.org/policies/tiles/).
New locations are geocoded with Nominatim through geopy.

## Development

You need [uv](https://docs.astral.sh/uv/) and a PostgreSQL server.

```console
$ 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):

```console
$ 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 |
| `EXPORT_PASSWORD` | Enables `/export/json` behind HTTP basic auth (any username). Unset means the endpoint 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.

```console
$ git push heroku master
```

## 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.
128 changes: 0 additions & 128 deletions db_pg.py

This file was deleted.

47 changes: 0 additions & 47 deletions main.py

This file was deleted.

87 changes: 0 additions & 87 deletions map.py

This file was deleted.

Loading
Loading