Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -41,16 +41,18 @@ import Counting_Columns_2_1
|
|
| 41 |
import Find_Hyperlinking_text
|
| 42 |
import ezdxf
|
| 43 |
from flask import Flask, render_template, session, redirect, url_for
|
| 44 |
-
|
| 45 |
app = Flask(__name__)
|
| 46 |
|
| 47 |
-
# Configure Flask-Session
|
| 48 |
-
app.config["SESSION_TYPE"] = "filesystem"
|
| 49 |
app.config["SESSION_PERMANENT"] = False
|
| 50 |
-
app.config["SESSION_FILE_DIR"] = "/tmp" #
|
| 51 |
app.secret_key = "your_secret_key" # Replace with a secure key
|
| 52 |
|
| 53 |
-
|
|
|
|
|
|
|
| 54 |
|
| 55 |
|
| 56 |
prjnamesURL= 'https://docs.google.com/spreadsheets/d/1nsIgi9o9VSBKQlNxbxihPzG_N7s4um0eNVfgL4gaGPc/export?format=csv&gid=0'
|
|
@@ -70,30 +72,29 @@ def getInfotoMeasure():
|
|
| 70 |
# Password Page Route
|
| 71 |
@app.route("/password", methods=["GET", "POST"])
|
| 72 |
def password_page():
|
| 73 |
-
return render_template("gui2.html")
|
| 74 |
|
| 75 |
# Check Password Route
|
| 76 |
@app.route("/check_password", methods=["POST"])
|
| 77 |
def check_password():
|
| 78 |
-
password = request.form.get("password")
|
| 79 |
-
correct_password = "c900"
|
| 80 |
|
| 81 |
if password == correct_password:
|
| 82 |
-
session["authenticated"] = True # Store authentication
|
| 83 |
-
return jsonify({"authenticated": True}), 200
|
| 84 |
else:
|
| 85 |
-
return jsonify({"authenticated": False}), 200
|
| 86 |
|
| 87 |
# Main GUI Route (Checks Authentication)
|
| 88 |
@app.route("/mainGUI", methods=["GET", "POST"])
|
| 89 |
def main_gui():
|
| 90 |
-
print("Session data:", session) # Debugging:
|
| 91 |
|
| 92 |
if "authenticated" not in session or not session["authenticated"]:
|
| 93 |
-
return redirect(url_for("gui2.html"))
|
| 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():
|
|
|
|
| 41 |
import Find_Hyperlinking_text
|
| 42 |
import ezdxf
|
| 43 |
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'
|
|
|
|
| 72 |
# Password Page Route
|
| 73 |
@app.route("/password", methods=["GET", "POST"])
|
| 74 |
def password_page():
|
| 75 |
+
return render_template("gui2.html")
|
| 76 |
|
| 77 |
# Check Password Route
|
| 78 |
@app.route("/check_password", methods=["POST"])
|
| 79 |
def check_password():
|
| 80 |
+
password = request.form.get("password")
|
| 81 |
+
correct_password = "c900"
|
| 82 |
|
| 83 |
if password == correct_password:
|
| 84 |
+
session["authenticated"] = True # Store authentication in session
|
| 85 |
+
return jsonify({"authenticated": True}), 200
|
| 86 |
else:
|
| 87 |
+
return jsonify({"authenticated": False}), 200
|
| 88 |
|
| 89 |
# Main GUI Route (Checks Authentication)
|
| 90 |
@app.route("/mainGUI", methods=["GET", "POST"])
|
| 91 |
def main_gui():
|
| 92 |
+
print("Session data:", session) # Debugging: check session contents
|
| 93 |
|
| 94 |
if "authenticated" not in session or not session["authenticated"]:
|
| 95 |
+
return redirect(url_for("gui2.html"))
|
|
|
|
|
|
|
| 96 |
|
| 97 |
+
return render_template("proposed-GUI.html")
|
| 98 |
|
| 99 |
@app.route("/WordSearch",methods=["GET", "POST"])
|
| 100 |
def getInfo2toMeasure():
|