abdullahalioo commited on
Commit
28f0870
·
verified ·
1 Parent(s): 0448f45

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -3
app.py CHANGED
@@ -2,6 +2,7 @@ import os
2
  import logging
3
  from flask import Flask
4
  from flask_sqlalchemy import SQLAlchemy
 
5
  from sqlalchemy.orm import DeclarativeBase
6
  from werkzeug.middleware.proxy_fix import ProxyFix
7
 
@@ -19,11 +20,12 @@ 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
- # 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")
@@ -52,6 +54,9 @@ app.config['ALLOWED_EXTENSIONS'] = {
52
  # Initialize database with app
53
  db.init_app(app)
54
 
 
 
 
55
  # Ensure upload directory exists
56
  os.makedirs(app.config['UPLOAD_FOLDER'], exist_ok=True)
57
 
 
2
  import logging
3
  from flask import Flask
4
  from flask_sqlalchemy import SQLAlchemy
5
+ from flask_session import Session
6
  from sqlalchemy.orm import DeclarativeBase
7
  from werkzeug.middleware.proxy_fix import ProxyFix
8
 
 
20
  app.secret_key = os.environ.get("SESSION_SECRET", "dev-secret-key")
21
  app.wsgi_app = ProxyFix(app.wsgi_app, x_proto=1, x_host=1)
22
 
23
+ # Session configuration
24
+ app.config['SESSION_COOKIE_SECURE'] = False # Allow non-HTTPS for Hugging Face
25
  app.config['SESSION_COOKIE_HTTPONLY'] = True
26
+ app.config['SESSION_COOKIE_SAMESITE'] = None # Allow cross-site cookies
27
  app.config['PERMANENT_SESSION_LIFETIME'] = 86400 # 24 hours
28
+ app.config['SESSION_TYPE'] = 'filesystem' # Use filesystem to store sessions
29
 
30
  # Configure database
31
  db_url = os.environ.get("DATABASE_URL")
 
54
  # Initialize database with app
55
  db.init_app(app)
56
 
57
+ # Initialize Flask-Session
58
+ Session(app)
59
+
60
  # Ensure upload directory exists
61
  os.makedirs(app.config['UPLOAD_FOLDER'], exist_ok=True)
62