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

+15 -3
View File
@@ -11,12 +11,18 @@ play videos from different camera views.
import os
import re
from dotenv import load_dotenv
from flask import Flask, render_template, send_from_directory, abort
# Load variables from a .env file if present (does not override real env vars)
load_dotenv()
app = Flask(__name__)
# Root TeslaCam directory containing RecentClips, SavedClips, SentryClips, etc.
TESLACAM_DIRECTORY = '/mnt/TeslaCam'
# Override via the TESLACAM_DIRECTORY environment variable (see .env.example).
TESLACAM_DIRECTORY = os.environ.get('TESLACAM_DIRECTORY', '/mnt/TeslaCam')
# Regular expression matching TeslaCam filenames: YYYY-MM-DD_HH-MM-SS-${camera_view}.mp4
VIDEO_FILENAME_REGEX = re.compile(
@@ -132,5 +138,11 @@ def serve_video(filepath):
if __name__ == '__main__':
host = '0.0.0.0'
app.run(debug=True, host=host, port=5000)
# Local dev server. For production, run behind a WSGI server instead, e.g.:
# gunicorn -w 4 -b 0.0.0.0:5000 'videoplayer:app'
# or
# waitress-serve --host=0.0.0.0 --port=5000 videoplayer:app
host = os.environ.get('FLASK_RUN_HOST', '0.0.0.0')
port = int(os.environ.get('FLASK_RUN_PORT', '5000'))
debug = os.environ.get('FLASK_DEBUG', '0').lower() in ('1', 'true', 'yes')
app.run(debug=debug, host=host, port=port)