Marthee commited on
Commit
59b1e8f
·
verified ·
1 Parent(s): 75c836d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -13
app.py CHANGED
@@ -44,24 +44,25 @@ from flask import Flask, render_template, session, redirect, url_for
44
  from flask_session import Session # Capital "S"
45
  app = Flask(__name__)
46
 
 
47
  # Configure Flask-Session for server-side session storage
48
- app.config["SESSION_TYPE"] = "filesystem"
49
- app.config["SESSION_PERMANENT"] = False
50
- app.config["SESSION_FILE_DIR"] = "/tmp" # Hugging Face temporary storage
51
- app.secret_key = "your_secret_key" # Replace with a secure key
52
 
53
- # Initialize Flask-Session (Fixed)
54
  sess = Session()
55
- sess.init_app(app)
56
-
57
 
58
- prjnamesURL= 'https://docs.google.com/spreadsheets/d/1nsIgi9o9VSBKQlNxbxihPzG_N7s4um0eNVfgL4gaGPc/export?format=csv&gid=0'
59
- prjpartsURL= 'https://docs.google.com/spreadsheets/d/1nsIgi9o9VSBKQlNxbxihPzG_N7s4um0eNVfgL4gaGPc/export?format=csv&gid=34865056'
60
- prjsectionsURL= 'https://docs.google.com/spreadsheets/d/1nsIgi9o9VSBKQlNxbxihPzG_N7s4um0eNVfgL4gaGPc/export?format=csv&gid=1751466819'
61
 
 
62
  global colorsused
63
  global pdflink
64
- #for 2.7
65
  global hatched_areas2_7
66
 
67
  @app.route("/", methods=["GET", "POST"])
@@ -77,8 +78,9 @@ def password_page():
77
  @app.route("/check_password", methods=["POST"])
78
  def check_password():
79
  password = request.form.get("password")
80
- correct_password = "c900"
81
 
 
82
  if password == correct_password:
83
  session["authenticated"] = True # Store authentication in session
84
  print("Password correct. Session data set:", session) # Debugging: Print session after setting it
@@ -91,14 +93,22 @@ def check_password():
91
  def main_gui():
92
  print("Session data at mainGUI:", session) # Debugging: Check session data
93
 
94
- # If session does not have "authenticated" or it is False, redirect to password page
 
 
 
 
 
 
95
  if "authenticated" not in session or not session["authenticated"]:
96
  print("User not authenticated, redirecting to password page.") # Debugging
97
  return redirect(url_for("password_page"))
98
 
 
99
  return render_template("proposed-GUI.html")
100
 
101
 
 
102
 
103
  @app.route("/WordSearch",methods=["GET", "POST"])
104
  def getInfo2toMeasure():
 
44
  from flask_session import Session # Capital "S"
45
  app = Flask(__name__)
46
 
47
+
48
  # Configure Flask-Session for server-side session storage
49
+ app.config["SESSION_TYPE"] = "filesystem" # Using filesystem for session storage (change as needed)
50
+ app.config["SESSION_PERMANENT"] = False # Sessions are not permanent
51
+ app.config["SESSION_FILE_DIR"] = "/tmp" # Temporary storage directory (adjust for Hugging Face)
52
+ app.secret_key = "your_secret_key" # Replace with a secure key for session signing
53
 
54
+ # Initialize Flask-Session
55
  sess = Session()
56
+ sess.init_app(app)
 
57
 
58
+ prjnamesURL = 'https://docs.google.com/spreadsheets/d/1nsIgi9o9VSBKQlNxbxihPzG_N7s4um0eNVfgL4gaGPc/export?format=csv&gid=0'
59
+ prjpartsURL = 'https://docs.google.com/spreadsheets/d/1nsIgi9o9VSBKQlNxbxihPzG_N7s4um0eNVfgL4gaGPc/export?format=csv&gid=34865056'
60
+ prjsectionsURL = 'https://docs.google.com/spreadsheets/d/1nsIgi9o9VSBKQlNxbxihPzG_N7s4um0eNVfgL4gaGPc/export?format=csv&gid=1751466819'
61
 
62
+ # Global variables (example)
63
  global colorsused
64
  global pdflink
65
+ # For 2.7
66
  global hatched_areas2_7
67
 
68
  @app.route("/", methods=["GET", "POST"])
 
78
  @app.route("/check_password", methods=["POST"])
79
  def check_password():
80
  password = request.form.get("password")
81
+ correct_password = "c900" # Correct password
82
 
83
+ # Check if the entered password matches the correct password
84
  if password == correct_password:
85
  session["authenticated"] = True # Store authentication in session
86
  print("Password correct. Session data set:", session) # Debugging: Print session after setting it
 
93
  def main_gui():
94
  print("Session data at mainGUI:", session) # Debugging: Check session data
95
 
96
+ # Debugging session contents before redirection
97
+ if "authenticated" not in session:
98
+ print("Session does not contain 'authenticated'") # Debugging
99
+ else:
100
+ print(f"Session['authenticated'] = {session['authenticated']}") # Debugging
101
+
102
+ # If the session does not have "authenticated" or it's False, redirect to the password page
103
  if "authenticated" not in session or not session["authenticated"]:
104
  print("User not authenticated, redirecting to password page.") # Debugging
105
  return redirect(url_for("password_page"))
106
 
107
+ # If authenticated, render the main GUI
108
  return render_template("proposed-GUI.html")
109
 
110
 
111
+
112
 
113
  @app.route("/WordSearch",methods=["GET", "POST"])
114
  def getInfo2toMeasure():