Spaces:
Running
Running
Commit ·
e5f88a5
1
Parent(s): d3adccb
10thg
Browse files- app.py +49 -9
- templates/index.html +11 -12
app.py
CHANGED
|
@@ -279,25 +279,39 @@ def index():
|
|
| 279 |
@app.route('/evaluate', methods=['GET', 'POST'])
|
| 280 |
def evaluate():
|
| 281 |
"""Display a document for evaluation or process evaluation form."""
|
| 282 |
-
# Extensive debug logging
|
| 283 |
log_error(f"Starting /evaluate route, session: {session}")
|
| 284 |
|
| 285 |
-
#
|
| 286 |
-
|
| 287 |
|
| 288 |
-
#
|
| 289 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 290 |
|
| 291 |
-
#
|
| 292 |
-
|
| 293 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 294 |
|
| 295 |
-
#
|
| 296 |
if not evaluator_name:
|
| 297 |
flash("Please enter your name before evaluating documents.")
|
| 298 |
log_error("No evaluator name found, redirecting to index")
|
| 299 |
return redirect(url_for('index'))
|
| 300 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 301 |
# Process POST request (form submission)
|
| 302 |
if request.method == 'POST':
|
| 303 |
# Process evaluation form...
|
|
@@ -503,6 +517,32 @@ def copy_template_if_needed():
|
|
| 503 |
except Exception as e:
|
| 504 |
print(f"Error copying template: {str(e)}")
|
| 505 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 506 |
if __name__ == '__main__':
|
| 507 |
print("\n===== Application Startup at", datetime.now().strftime('%Y-%m-%d %H:%M:%S'), "=====\n")
|
| 508 |
|
|
|
|
| 279 |
@app.route('/evaluate', methods=['GET', 'POST'])
|
| 280 |
def evaluate():
|
| 281 |
"""Display a document for evaluation or process evaluation form."""
|
|
|
|
| 282 |
log_error(f"Starting /evaluate route, session: {session}")
|
| 283 |
|
| 284 |
+
# Try multiple methods to get evaluator name
|
| 285 |
+
evaluator_name = session.get('evaluator_name', '')
|
| 286 |
|
| 287 |
+
# If not in session, check query parameter
|
| 288 |
+
if not evaluator_name and request.args.get('evaluator'):
|
| 289 |
+
evaluator_name = request.args.get('evaluator')
|
| 290 |
+
session['evaluator_name'] = evaluator_name
|
| 291 |
+
store_evaluator_name(evaluator_name)
|
| 292 |
+
log_error(f"Got evaluator name from query param: {evaluator_name}")
|
| 293 |
|
| 294 |
+
# If still not found, try file-based storage
|
| 295 |
+
if not evaluator_name:
|
| 296 |
+
evaluator_name = get_stored_evaluator_name()
|
| 297 |
+
if evaluator_name:
|
| 298 |
+
session['evaluator_name'] = evaluator_name
|
| 299 |
+
log_error(f"Got evaluator name from file: {evaluator_name}")
|
| 300 |
+
|
| 301 |
+
log_error(f"Final evaluator name: {evaluator_name}")
|
| 302 |
|
| 303 |
+
# Still no evaluator name, redirect to index with a message
|
| 304 |
if not evaluator_name:
|
| 305 |
flash("Please enter your name before evaluating documents.")
|
| 306 |
log_error("No evaluator name found, redirecting to index")
|
| 307 |
return redirect(url_for('index'))
|
| 308 |
|
| 309 |
+
# Make sure data directory exists
|
| 310 |
+
ensure_data_directory()
|
| 311 |
+
|
| 312 |
+
# Create sessions directory if it doesn't exist
|
| 313 |
+
os.makedirs(os.path.join(DATA_DIR, 'sessions'), exist_ok=True)
|
| 314 |
+
|
| 315 |
# Process POST request (form submission)
|
| 316 |
if request.method == 'POST':
|
| 317 |
# Process evaluation form...
|
|
|
|
| 517 |
except Exception as e:
|
| 518 |
print(f"Error copying template: {str(e)}")
|
| 519 |
|
| 520 |
+
def store_evaluator_name(name):
|
| 521 |
+
"""Store evaluator name in a file for persistence"""
|
| 522 |
+
try:
|
| 523 |
+
ensure_data_directory()
|
| 524 |
+
with open(os.path.join(DATA_DIR, 'current_evaluator.txt'), 'w') as f:
|
| 525 |
+
f.write(name)
|
| 526 |
+
log_error(f"Stored evaluator name in file: {name}")
|
| 527 |
+
return True
|
| 528 |
+
except Exception as e:
|
| 529 |
+
log_error(f"Error storing evaluator name: {str(e)}")
|
| 530 |
+
return False
|
| 531 |
+
|
| 532 |
+
def get_stored_evaluator_name():
|
| 533 |
+
"""Get stored evaluator name from file"""
|
| 534 |
+
try:
|
| 535 |
+
file_path = os.path.join(DATA_DIR, 'current_evaluator.txt')
|
| 536 |
+
if os.path.exists(file_path):
|
| 537 |
+
with open(file_path, 'r') as f:
|
| 538 |
+
name = f.read().strip()
|
| 539 |
+
log_error(f"Retrieved evaluator name from file: {name}")
|
| 540 |
+
return name
|
| 541 |
+
return None
|
| 542 |
+
except Exception as e:
|
| 543 |
+
log_error(f"Error retrieving evaluator name: {str(e)}")
|
| 544 |
+
return None
|
| 545 |
+
|
| 546 |
if __name__ == '__main__':
|
| 547 |
print("\n===== Application Startup at", datetime.now().strftime('%Y-%m-%d %H:%M:%S'), "=====\n")
|
| 548 |
|
templates/index.html
CHANGED
|
@@ -231,18 +231,17 @@
|
|
| 231 |
</div>
|
| 232 |
|
| 233 |
<div class="fallback-links" style="margin-top: 20px; padding: 15px; background-color: #f8f9fa; border-radius: 8px;">
|
| 234 |
-
<h3>
|
| 235 |
-
<p>
|
| 236 |
-
<
|
| 237 |
-
<
|
| 238 |
-
|
| 239 |
-
|
| 240 |
-
|
| 241 |
-
|
| 242 |
-
|
| 243 |
-
|
| 244 |
-
|
| 245 |
-
</ol>
|
| 246 |
</div>
|
| 247 |
</div>
|
| 248 |
</body>
|
|
|
|
| 231 |
</div>
|
| 232 |
|
| 233 |
<div class="fallback-links" style="margin-top: 20px; padding: 15px; background-color: #f8f9fa; border-radius: 8px;">
|
| 234 |
+
<h3>Direct Access to Evaluation</h3>
|
| 235 |
+
<p>You can access the evaluation page directly by entering your name and clicking the button below:</p>
|
| 236 |
+
<div style="margin-top: 15px;">
|
| 237 |
+
<form action="{{ url_for('evaluate') }}" method="GET">
|
| 238 |
+
<div style="display: flex; gap: 10px; margin-bottom: 15px;">
|
| 239 |
+
<input type="text" name="evaluator" placeholder="Your Name" required style="flex: 1; padding: 8px;">
|
| 240 |
+
<button type="submit" class="submit-btn">Start Evaluation</button>
|
| 241 |
+
</div>
|
| 242 |
+
</form>
|
| 243 |
+
</div>
|
| 244 |
+
<p><strong>Note:</strong> If you're having trouble with the file upload method, this direct access approach may work better.</p>
|
|
|
|
| 245 |
</div>
|
| 246 |
</div>
|
| 247 |
</body>
|