Update app.py
Browse files
app.py
CHANGED
|
@@ -29,14 +29,11 @@ from datetime import datetime
|
|
| 29 |
import io
|
| 30 |
import secrets
|
| 31 |
import traceback
|
| 32 |
-
|
| 33 |
from dotenv import load_dotenv
|
| 34 |
|
| 35 |
-
load_dotenv()
|
| 36 |
-
|
| 37 |
current_analysis_data = {}
|
| 38 |
|
| 39 |
-
|
| 40 |
|
| 41 |
#===========================================================================
|
| 42 |
# Clear the /tmp directory on startup
|
|
@@ -147,11 +144,11 @@ app.config['SECRET_KEY'] = os.getenv('SECRET_KEY', secrets.token_hex(32))
|
|
| 147 |
app.config['UPLOAD_FOLDER'] = 'uploads'
|
| 148 |
app.config['MAX_CONTENT_LENGTH'] = 16 * 1024 * 1024 # 16MB max file size
|
| 149 |
|
| 150 |
-
# Session configuration for production
|
| 151 |
-
app.config['SESSION_COOKIE_SECURE'] = True # Set to True if using HTTPS
|
| 152 |
-
app.config['SESSION_COOKIE_HTTPONLY'] = True
|
| 153 |
-
app.config['SESSION_COOKIE_SAMESITE'] = 'Lax'
|
| 154 |
-
app.config['PERMANENT_SESSION_LIFETIME'] = 3600 # 1 hour
|
| 155 |
|
| 156 |
|
| 157 |
os.makedirs(app.config['UPLOAD_FOLDER'], exist_ok=True)
|
|
@@ -704,20 +701,16 @@ def export_csv():
|
|
| 704 |
Retrieves the transformed_data from session and creates a CSV download.
|
| 705 |
"""
|
| 706 |
try:
|
| 707 |
-
#
|
| 708 |
-
|
| 709 |
-
transformed_data =
|
| 710 |
|
| 711 |
-
# Option 2: From global variable (if you stored it there)
|
| 712 |
-
# transformed_data = current_analysis_results
|
| 713 |
-
|
| 714 |
if not transformed_data:
|
| 715 |
-
print("
|
| 716 |
-
|
| 717 |
-
|
|
|
|
| 718 |
|
| 719 |
-
if not transformed_data:
|
| 720 |
-
return jsonify({'error': 'No analysis data available'}), 400
|
| 721 |
|
| 722 |
# Create CSV in memory
|
| 723 |
output = io.StringIO()
|
|
|
|
| 29 |
import io
|
| 30 |
import secrets
|
| 31 |
import traceback
|
|
|
|
| 32 |
from dotenv import load_dotenv
|
| 33 |
|
|
|
|
|
|
|
| 34 |
current_analysis_data = {}
|
| 35 |
|
| 36 |
+
load_dotenv()
|
| 37 |
|
| 38 |
#===========================================================================
|
| 39 |
# Clear the /tmp directory on startup
|
|
|
|
| 144 |
app.config['UPLOAD_FOLDER'] = 'uploads'
|
| 145 |
app.config['MAX_CONTENT_LENGTH'] = 16 * 1024 * 1024 # 16MB max file size
|
| 146 |
|
| 147 |
+
# # Session configuration for production
|
| 148 |
+
# app.config['SESSION_COOKIE_SECURE'] = True # Set to True if using HTTPS
|
| 149 |
+
# app.config['SESSION_COOKIE_HTTPONLY'] = True
|
| 150 |
+
# app.config['SESSION_COOKIE_SAMESITE'] = 'Lax'
|
| 151 |
+
# app.config['PERMANENT_SESSION_LIFETIME'] = 3600 # 1 hour
|
| 152 |
|
| 153 |
|
| 154 |
os.makedirs(app.config['UPLOAD_FOLDER'], exist_ok=True)
|
|
|
|
| 701 |
Retrieves the transformed_data from session and creates a CSV download.
|
| 702 |
"""
|
| 703 |
try:
|
| 704 |
+
# Use ONLY global variable (no session)
|
| 705 |
+
global current_analysis_data
|
| 706 |
+
transformed_data = current_analysis_data
|
| 707 |
|
|
|
|
|
|
|
|
|
|
| 708 |
if not transformed_data:
|
| 709 |
+
print("❌ No analysis data available in global variable")
|
| 710 |
+
return jsonify({'error': 'No analysis data available. Please run analysis first.'}), 400
|
| 711 |
+
|
| 712 |
+
print(f"✓ Found data: Risk Level = {transformed_data.get('risk_level', 'N/A')}")
|
| 713 |
|
|
|
|
|
|
|
| 714 |
|
| 715 |
# Create CSV in memory
|
| 716 |
output = io.StringIO()
|