Spaces:
Sleeping
Sleeping
Commit
·
0213c17
1
Parent(s):
42c9da4
changes
Browse files
app.py
CHANGED
|
@@ -7,6 +7,8 @@ import logging
|
|
| 7 |
import sys
|
| 8 |
from utils.ai_helpers import generate_notebook, stream_notebook_generation, stream_notebook_edit, edit_notebook
|
| 9 |
from utils.notebook_helpers import format_notebook, extract_notebook_info
|
|
|
|
|
|
|
| 10 |
|
| 11 |
# Configure logging
|
| 12 |
logging.basicConfig(
|
|
@@ -31,6 +33,10 @@ if IS_HUGGINGFACE:
|
|
| 31 |
app.config["SESSION_FILE_THRESHOLD"] = 10 # Low threshold to ensure writes
|
| 32 |
# Important: Don't use large session lifetime on Hugging Face
|
| 33 |
app.config["PERMANENT_SESSION_LIFETIME"] = 60 * 60 * 24 # 1 day only
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
|
| 35 |
# Map front-end model names to API model names
|
| 36 |
MODEL_MAPPING = {
|
|
|
|
| 7 |
import sys
|
| 8 |
from utils.ai_helpers import generate_notebook, stream_notebook_generation, stream_notebook_edit, edit_notebook
|
| 9 |
from utils.notebook_helpers import format_notebook, extract_notebook_info
|
| 10 |
+
# Added for server-side sessions
|
| 11 |
+
from flask_session import Session
|
| 12 |
|
| 13 |
# Configure logging
|
| 14 |
logging.basicConfig(
|
|
|
|
| 33 |
app.config["SESSION_FILE_THRESHOLD"] = 10 # Low threshold to ensure writes
|
| 34 |
# Important: Don't use large session lifetime on Hugging Face
|
| 35 |
app.config["PERMANENT_SESSION_LIFETIME"] = 60 * 60 * 24 # 1 day only
|
| 36 |
+
# Added: Use server-side sessions to persist API keys across workers
|
| 37 |
+
app.config["SESSION_TYPE"] = "filesystem"
|
| 38 |
+
app.config["SESSION_FILE_DIR"] = os.path.join(os.getcwd(), "flask_session")
|
| 39 |
+
Session(app)
|
| 40 |
|
| 41 |
# Map front-end model names to API model names
|
| 42 |
MODEL_MAPPING = {
|