Skip to content

Commit c46be44

Browse files
committed
handle security risks
1 parent 77c00ff commit c46be44

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

api/app_factory.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@
2222
def create_app():
2323
"""Create and configure the Flask application."""
2424
app = Flask(__name__)
25-
app.secret_key = os.getenv("FLASK_SECRET_KEY", "supersekrit")
25+
app.secret_key = os.getenv("FLASK_SECRET_KEY")
26+
if not app.secret_key:
27+
import secrets
28+
app.secret_key = secrets.token_hex(32)
29+
logging.warning("FLASK_SECRET_KEY not set, using generated key. Set this in production!")
2630

2731
# Google OAuth setup
2832
GOOGLE_CLIENT_ID = os.getenv("GOOGLE_CLIENT_ID")

api/index.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,9 @@
55
app = create_app()
66

77
if __name__ == "__main__":
8-
app.run(debug=True)
8+
import os
9+
debug_mode = os.environ.get('FLASK_DEBUG', 'False').lower() == 'true'
10+
app.run(debug=debug_mode)
11+
# This allows running the app with `flask run` or directly with `python api/index.py`
12+
# Ensure the environment variable FLASK_DEBUG is set to 'True' for debug mode
13+
# or 'False' for production mode.

0 commit comments

Comments
 (0)