Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -19,8 +19,17 @@ app = Flask(__name__)
|
|
19 |
app.secret_key = os.environ.get("SESSION_SECRET", "dev-secret-key")
|
20 |
app.wsgi_app = ProxyFix(app.wsgi_app, x_proto=1, x_host=1)
|
21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
# Configure database
|
23 |
-
|
|
|
|
|
|
|
24 |
app.config["SQLALCHEMY_ENGINE_OPTIONS"] = {
|
25 |
"pool_recycle": 300,
|
26 |
"pool_pre_ping": True,
|
|
|
19 |
app.secret_key = os.environ.get("SESSION_SECRET", "dev-secret-key")
|
20 |
app.wsgi_app = ProxyFix(app.wsgi_app, x_proto=1, x_host=1)
|
21 |
|
22 |
+
# Session configuration for better security and reliability
|
23 |
+
app.config['SESSION_COOKIE_SECURE'] = True
|
24 |
+
app.config['SESSION_COOKIE_HTTPONLY'] = True
|
25 |
+
app.config['SESSION_COOKIE_SAMESITE'] = 'Lax'
|
26 |
+
app.config['PERMANENT_SESSION_LIFETIME'] = 86400 # 24 hours
|
27 |
+
|
28 |
# Configure database
|
29 |
+
db_url = os.environ.get("DATABASE_URL")
|
30 |
+
if db_url and db_url.startswith("postgres://"):
|
31 |
+
db_url = db_url.replace("postgres://", "postgresql://", 1)
|
32 |
+
app.config["SQLALCHEMY_DATABASE_URI"] = db_url or "sqlite:///whatsapp_clone.db"
|
33 |
app.config["SQLALCHEMY_ENGINE_OPTIONS"] = {
|
34 |
"pool_recycle": 300,
|
35 |
"pool_pre_ping": True,
|