Skip to content

Commit 45e41bc

Browse files
committed
updating readme
1 parent db17906 commit 45e41bc

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,3 +352,40 @@ prod:
352352
export P_PROFILE=prod
353353
python app.py
354354
```
355+
356+
## Example: containerized / twelve-factor app
357+
358+
No config file needed. Parameters come entirely from environment variables — the [twelve-factor](https://12factor.net/config) way. A `.env` file is picked up automatically in local development; in production, env vars are injected by the container runtime.
359+
360+
**`app.py`**
361+
```python
362+
import paramflow as pf
363+
364+
params = pf.load() # no file — reads from .env locally, env vars in production
365+
366+
# read params
367+
params.db_url
368+
params.debug
369+
params.port
370+
```
371+
372+
**`.env`** (local development, not committed to version control)
373+
```
374+
P_DB_URL=postgres://localhost/mydb
375+
P_DEBUG=true
376+
P_PORT=8080
377+
```
378+
379+
Run locally — `.env` is discovered automatically:
380+
```sh
381+
python app.py
382+
```
383+
384+
Run in production — env vars injected by the container:
385+
```sh
386+
docker run \
387+
-e P_DB_URL=postgres://prod-db/mydb \
388+
-e P_DEBUG=false \
389+
-e P_PORT=8080 \
390+
myapp
391+
```

0 commit comments

Comments
 (0)