Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -43,6 +43,14 @@ import ezdxf
|
|
| 43 |
from flask import Flask, render_template, session, redirect, url_for
|
| 44 |
|
| 45 |
app = Flask(__name__)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
|
| 47 |
|
| 48 |
prjnamesURL= 'https://docs.google.com/spreadsheets/d/1nsIgi9o9VSBKQlNxbxihPzG_N7s4um0eNVfgL4gaGPc/export?format=csv&gid=0'
|
|
@@ -53,41 +61,40 @@ global colorsused
|
|
| 53 |
global pdflink
|
| 54 |
#for 2.7
|
| 55 |
global hatched_areas2_7
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
app.secret_key = 'your_secret_key' # Make sure you have a secret key for session management
|
| 59 |
|
| 60 |
-
|
| 61 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
@app.route("/password", methods=["GET", "POST"])
|
| 63 |
def password_page():
|
| 64 |
return render_template("gui2.html") # Render the password page (gui2.html)
|
| 65 |
|
| 66 |
-
# Password
|
| 67 |
@app.route("/check_password", methods=["POST"])
|
| 68 |
def check_password():
|
| 69 |
-
password = request.form.get(
|
| 70 |
-
correct_password =
|
| 71 |
|
| 72 |
-
if password == correct_password:
|
| 73 |
-
session[
|
| 74 |
-
return {"authenticated": True}, 200 # Respond with success
|
| 75 |
else:
|
| 76 |
-
return {"authenticated": False}, 200 # Respond with failure
|
| 77 |
|
| 78 |
-
# Main GUI
|
| 79 |
@app.route("/mainGUI", methods=["GET", "POST"])
|
| 80 |
def main_gui():
|
| 81 |
-
|
| 82 |
-
return redirect(url_for('password_page')) # Redirect to the password page if not authenticated
|
| 83 |
-
return render_template("proposed-GUI.html") # Main page content after successful password check
|
| 84 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 85 |
|
| 86 |
|
| 87 |
-
@app.route("/",methods=["GET", "POST"])
|
| 88 |
-
def getInfotoMeasure():
|
| 89 |
-
# API.AppendtablestoSheets()
|
| 90 |
-
return render_template("gui2.html")
|
| 91 |
@app.route("/WordSearch",methods=["GET", "POST"])
|
| 92 |
def getInfo2toMeasure():
|
| 93 |
# API.AppendtablestoSheets()
|
|
|
|
| 43 |
from flask import Flask, render_template, session, redirect, url_for
|
| 44 |
|
| 45 |
app = Flask(__name__)
|
| 46 |
+
|
| 47 |
+
# Configure Flask-Session to store session data on the server (needed for Hugging Face Spaces)
|
| 48 |
+
app.config["SESSION_TYPE"] = "filesystem" # Store sessions in temporary files
|
| 49 |
+
app.config["SESSION_PERMANENT"] = False
|
| 50 |
+
app.config["SESSION_FILE_DIR"] = "/tmp" # Use Hugging Face's temporary directory
|
| 51 |
+
app.secret_key = "your_secret_key" # Replace with a secure key
|
| 52 |
+
|
| 53 |
+
Session(app) # Initialize Flask-Session
|
| 54 |
|
| 55 |
|
| 56 |
prjnamesURL= 'https://docs.google.com/spreadsheets/d/1nsIgi9o9VSBKQlNxbxihPzG_N7s4um0eNVfgL4gaGPc/export?format=csv&gid=0'
|
|
|
|
| 61 |
global pdflink
|
| 62 |
#for 2.7
|
| 63 |
global hatched_areas2_7
|
|
|
|
|
|
|
|
|
|
| 64 |
|
| 65 |
+
@app.route("/",methods=["GET", "POST"])
|
| 66 |
+
def getInfotoMeasure():
|
| 67 |
+
# API.AppendtablestoSheets()
|
| 68 |
+
return render_template("gui2.html")
|
| 69 |
+
|
| 70 |
+
# Password Page Route
|
| 71 |
@app.route("/password", methods=["GET", "POST"])
|
| 72 |
def password_page():
|
| 73 |
return render_template("gui2.html") # Render the password page (gui2.html)
|
| 74 |
|
| 75 |
+
# Check Password Route
|
| 76 |
@app.route("/check_password", methods=["POST"])
|
| 77 |
def check_password():
|
| 78 |
+
password = request.form.get("password") # Get password from form input
|
| 79 |
+
correct_password = "c900" # Define the correct password
|
| 80 |
|
| 81 |
+
if password == correct_password:
|
| 82 |
+
session["authenticated"] = True # Store authentication status in session
|
| 83 |
+
return jsonify({"authenticated": True}), 200 # Respond with success
|
| 84 |
else:
|
| 85 |
+
return jsonify({"authenticated": False}), 200 # Respond with failure
|
| 86 |
|
| 87 |
+
# Main GUI Route (Checks Authentication)
|
| 88 |
@app.route("/mainGUI", methods=["GET", "POST"])
|
| 89 |
def main_gui():
|
| 90 |
+
print("Session data:", session) # Debugging: print session contents
|
|
|
|
|
|
|
| 91 |
|
| 92 |
+
if "authenticated" not in session or not session["authenticated"]:
|
| 93 |
+
return redirect(url_for("gui2.html")) # Redirect if not authenticated
|
| 94 |
+
|
| 95 |
+
return render_template("proposed-GUI.html") # Render the main GUI page
|
| 96 |
|
| 97 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 98 |
@app.route("/WordSearch",methods=["GET", "POST"])
|
| 99 |
def getInfo2toMeasure():
|
| 100 |
# API.AppendtablestoSheets()
|