Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
from flask import Flask, render_template, request, jsonify, redirect, url_for, session
|
2 |
-
from
|
|
|
3 |
from salesforce import get_salesforce_connection
|
4 |
import os
|
5 |
|
@@ -15,13 +16,14 @@ print("Salesforce connection established.")
|
|
15 |
# Set the secret key to handle sessions securely
|
16 |
app.secret_key = os.getenv("SECRET_KEY", "sSSjyhInIsUohKpG8sHzty2q") # Replace with a secure key
|
17 |
|
18 |
-
|
19 |
-
app.config["
|
20 |
-
app.config["
|
21 |
-
app.config["
|
22 |
-
app.config["SESSION_PERMANENT"] = False # Do not use permanent sessions
|
23 |
|
24 |
-
|
|
|
|
|
25 |
|
26 |
# Ensure secure session handling for environments like Hugging Face
|
27 |
app.session_interface = SecureCookieSessionInterface()
|
|
|
1 |
from flask import Flask, render_template, request, jsonify, redirect, url_for, session
|
2 |
+
from flask_session import Session # Import the Session class
|
3 |
+
import random
|
4 |
from salesforce import get_salesforce_connection
|
5 |
import os
|
6 |
|
|
|
16 |
# Set the secret key to handle sessions securely
|
17 |
app.secret_key = os.getenv("SECRET_KEY", "sSSjyhInIsUohKpG8sHzty2q") # Replace with a secure key
|
18 |
|
19 |
+
# Configure the session type
|
20 |
+
app.config["SESSION_TYPE"] = "filesystem" # Use filesystem for session storage
|
21 |
+
app.config["SESSION_COOKIE_SAMESITE"] = "None" # Allow cross-site cookies
|
22 |
+
app.config["SESSION_COOKIE_SECURE"] = True # Secure cookies over HTTPS
|
|
|
23 |
|
24 |
+
# Initialize the session
|
25 |
+
Session(app) # Correctly initialize the Session object
|
26 |
+
print("Session interface configured.")
|
27 |
|
28 |
# Ensure secure session handling for environments like Hugging Face
|
29 |
app.session_interface = SecureCookieSessionInterface()
|