DSatishchandra commited on
Commit
2ed1fc7
·
verified ·
1 Parent(s): 8a444f7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -1
app.py CHANGED
@@ -5,11 +5,30 @@ from salesforce import get_salesforce_connection
5
  import os
6
 
7
  # Initialize Flask app and Salesforce connection
 
8
  app = Flask(__name__)
 
 
 
9
  sf = get_salesforce_connection()
 
10
 
11
  # Set the secret key to handle sessions securely
12
- app.secret_key = 'sSSjyhInIsUohKpG8sHzty2q' # Replace with a secure key
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
 
14
  @app.route("/")
15
  def home():
 
5
  import os
6
 
7
  # Initialize Flask app and Salesforce connection
8
+ print("Starting app...")
9
  app = Flask(__name__)
10
+ print("Flask app initialized.")
11
+
12
+ # Add debug logs in Salesforce connection setup
13
  sf = get_salesforce_connection()
14
+ print("Salesforce connection established.")
15
 
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_NAME"] = "my_session" # Optional: Change session cookie name
22
+ app.config["SESSION_COOKIE_SECURE"] = True # Ensure cookies are sent over HTTPS
23
+ app.config["SESSION_COOKIE_SAMESITE"] = "None" # Allow cross-site cookies
24
+
25
+ # Initialize the session
26
+ Session(app) # Correctly initialize the Session object
27
+ print("Session interface configured.")
28
+
29
+ # Ensure secure session handling for environments like Hugging Face
30
+ app.session_interface = SecureCookieSessionInterface()
31
+ print("Session interface configured.")
32
 
33
  @app.route("/")
34
  def home():