sentiment-analysis / config.py
sabarish
Fix login loop for HF Spaces iframe using SameSite=None
af8ad03
raw
history blame contribute delete
914 Bytes
import os
from dotenv import load_dotenv
basedir = os.path.abspath(os.path.dirname(__file__))
load_dotenv(os.path.join(basedir, '.env'))
class Config:
SECRET_KEY = os.environ.get('SECRET_KEY') or 'you-will-never-guess-super-secret'
# MySQL Connection String Example: mysql+pymysql://user:password@localhost/dbname
# Fallback to SQLite if MySQL is not configured for easy testing
SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URL') or \
'sqlite:///' + os.path.join(basedir, 'sentiment.sqlite')
SQLALCHEMY_TRACK_MODIFICATIONS = False
# File upload handling
UPLOAD_FOLDER = os.path.join(basedir, 'uploads')
MAX_CONTENT_LENGTH = 16 * 1024 * 1024 # 16 MB max limit
ALLOWED_EXTENSIONS = {'csv', 'xls', 'xlsx'}
# Required for cross-site iframe sessions (Hugging Face Spaces)
SESSION_COOKIE_SAMESITE = 'None'
SESSION_COOKIE_SECURE = True