add .env.example and update README for environment variable configuration

This commit is contained in:
zwitschi committed 2026-07-24 12:49:25 +02:00
1 parent ae208bd39b
commit a4202afe30
5 files changed
+65 -12

No files matched your search

+38 -7
View File
@@ -26,7 +26,7 @@ tesla-cam-view-1/
## Requirements
- Python 3.x
- Flask (see `requirements.txt`)
- Flask, python-dotenv, gunicorn (see `requirements.txt`)
## Setup
@@ -46,17 +46,27 @@ tesla-cam-view-1/
pip install -r requirements.txt
```
3. Configure the TeslaCam directory by editing `TESLACAM_DIRECTORY` in `videoplayer.py`:
3. Configure the TeslaCam directory via environment variables. Copy the example
file and edit it:
```python
TESLACAM_DIRECTORY = r'W:\2026\USA2026\TeslaCam'
```bash
cp .env.example .env
```
Point this to the root folder containing your `RecentClips`, `SavedClips`, and `SentryClips` subfolders.
```ini
TESLACAM_DIRECTORY=/mnt/TeslaCam
FLASK_RUN_HOST=0.0.0.0
FLASK_RUN_PORT=5000
FLASK_DEBUG=0
```
`TESLACAM_DIRECTORY` should point to the root folder containing your
`RecentClips`, `SavedClips`, and `SentryClips` subfolders. Variables set in
the real environment take precedence over `.env`.
## Usage
Run the app:
### Local development server
```bash
python videoplayer.py
@@ -64,6 +74,26 @@ python videoplayer.py
Then open [http://localhost:5000](http://localhost:5000) in your browser.
### Production (WSGI server on Linux)
For production, run the app behind a WSGI server such as **gunicorn**. The
`app` object in `videoplayer.py` is the WSGI entry point:
```bash
gunicorn -w 4 -b 0.0.0.0:5000 'videoplayer:app'
```
`TESLACAM_DIRECTORY` is read from the environment (or `.env`), so make sure it
is set for the gunicorn process, e.g.:
```bash
export TESLACAM_DIRECTORY=/mnt/TeslaCam
gunicorn -w 4 -b 0.0.0.0:5000 'videoplayer:app'
```
For a systemd service or other process manager, set the variable in the unit
file / environment rather than relying on `.env`.
- The **main page** lists all clips grouped by camera view with a player and searchable clip list.
- Click a clip to play it; use the camera switch buttons to jump between angles for the same timestamp.
- The `/camera/<view>` route shows all clips for a single camera.
@@ -89,6 +119,7 @@ Then open [http://localhost:5000](http://localhost:5000) in your browser.
## Notes
- The app runs with `debug=True` by default — disable this for production use.
- Debug mode is off by default (`FLASK_DEBUG=0`) and is only used by the local
dev server. It has no effect when running under a WSGI server like gunicorn.
- The TeslaCam directory must be accessible from the machine running the app (e.g., a mounted USB drive or network share).
- Filename parsing assumes the standard TeslaCam naming format; files not matching the regex are ignored.