Spaces:
Build error
Build error
Commit ·
506c033
1
Parent(s): 4020dbd
update
Browse files102 unmodified lines1031041051061071081091101 unmodified line11211311411311511611711611811811912012112212312412512612712812913013113213313413513613713811912012112212330 unmodified lines154155156176157158159104 unmodified lines264265266267268269270271272289273102 unmodified lines
session['responses'] = [] # Initialize responses list session['username'] = username # Store the username for later use session['selected_samples'] = selected_samples # Store selected samples in session session['method'] = method # Store the method in session
return redirect(url_for('experiment', username=username, sample_index=0, seed=seed, filename=filename)) except Exception as e:1 unmodified line return "An error occurred", 500 return render_template('index.html')
@app.route('/experiment/<username>/<sample_index>/<seed>/<filename>', methods=['GET', 'POST'])@app.route('/experiment/<username>/<int:sample_index>/<seed>/<filename>', methods=['GET', 'POST'])def experiment(username, sample_index, seed, filename): try: sample_index = int(sample_index) selected_samples = session.get('selected_samples', [])
if request.method == 'POST': # Process feedback feedback = request.form.get('feedback') if not feedback: return "Feedback is required", 400
responses = session.get('responses', []) responses.append({ 'sample_id': sample_index, 'feedback': feedback }) session['responses'] = responses
next_sample_index = sample_index + 1 if next_sample_index >= len(selected_samples): return redirect(url_for('completed', filename=filename))
return redirect(url_for('experiment', username=username, sample_index=next_sample_index, seed=seed, filename=filename))
# Render the experiment page method = session.get('method')
if sample_index >= len(selected_samples): return redirect(url_for('completed', filename=filename))
30 unmodified lines logger.exception(f"An error occurred in the experiment route: {e}") return "An error occurred", 500
@app.route('/feedback', methods=['POST'])def feedback(): try:104 unmodified lines logger.exception(f"An error occurred in the completed route: {e}") return "An error occurred", 500
@app.route('/visualizations/<path:path>')def send_visualization(path): return send_from_directory('.', path)
if __name__ == "__main__": os.makedirs('session_data', exist_ok=True) # Ensure the directory for session files exists app.run(host="0.0.0.0", port=7860) app.run(host="0.0.0.0", port=7860, debug=True)app.py+9-25