Spaces:
Build error
Build error
Commit Β·
4600a8b
1
Parent(s): 2529cfa
update
Browse filesFiles changed (2)
- app.py+17-7
- templates/index.html+12-9
155 unmodified lines156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185155 unmodified lines'start_time': start_time,'session_id': session_id}session['data'] = session_data # Store data in session instead of committingreturn redirect(url_for('explanation', session_id=session_id))except Exception as e:logger.exception(f"Error in index route: {e}")return render_template('index.html', error="An error occurred. Please try again.")return render_template('index.html')@app.route('/explanation/<session_id>')def explanation(session_id):session_data = session.get('data')if not session_data:return redirect(url_for('index'))method = session_data['method']if method == 'Chain-of-Table':return render_template('cot_intro.html', session_id=session_id)elif method == 'Plan-of-SQLs':return render_template('pos_intro.html', session_id=session_id)elif method == 'Dater':return render_template('dater_intro.html', session_id=session_id)else: # No-XAIreturn redirect(url_for('experiment', session_id=session_id))@app.route('/experiment/<session_id>', methods=['GET', 'POST'])def experiment(session_id):155 unmodified lines156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195155 unmodified lines'start_time': start_time,'session_id': session_id}session['data'] = session_data # Store data in sessionlogger.info(f"Session data stored for user {username}, method {method}")# Redirect based on the selected methodif method == 'No-XAI':return redirect(url_for('experiment', session_id=session_id))else:return redirect(url_for('explanation', session_id=session_id))except Exception as e:logger.exception(f"Error in index route: {e}")return render_template('index.html', error="An error occurred. Please try again.")return render_template('index.html')@app.route('/explanation/<session_id>')def explanation(session_id):session_data = session.get('data')if not session_data:logger.error(f"No session data found for session ID: {session_id}")return redirect(url_for('index'))method = session_data.get('method')if not method:logger.error(f"No method found in session data for session ID: {session_id}")return redirect(url_for('index'))if method == 'Chain-of-Table':return render_template('cot_intro.html', session_id=session_id)elif method == 'Plan-of-SQLs':return render_template('pos_intro.html', session_id=session_id)elif method == 'Dater':return render_template('dater_intro.html', session_id=session_id)else:logger.error(f"Invalid method '{method}' for session ID: {session_id}")return redirect(url_for('index'))@app.route('/experiment/<session_id>', methods=['GET', 'POST'])def experiment(session_id):
73 unmodified lines7475767778798020 unmodified lines10110210310410510610722 unmodified lines13013113213313413520 unmodified lines15615715815916016116216316416516616719 unmodified lines18718818919019119217 unmodified lines21021121221321421521673 unmodified linesbackground-color: #fff3e0;color: #ff9800;}.task-instruction {background-color: #f0f8ff;border-left: 5px solid #4CAF50;20 unmodified linesfont-size: 18px;color: #333;}.method-button:hover {opacity: 0.8;}22 unmodified linesbutton:hover {background-color: #45a049;}</style><script>function selectMethod(method) {20 unmodified lines}return true;}function goToExplanation() {if (validateForm()) {document.getElementById('method-form').submit();}}</script><link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&display=swap" rel="stylesheet"></head>19 unmodified lines</div></div><form id="method-form" action="{{ url_for('index') }}" method="post" onsubmit="return validateForm();"><label for="username">Hi there πππ ! What is your name?</label><input type="text" id="username" name="username" required>17 unmodified lines</div></div><button type="button" onclick="goToExplanation()">Next</button></form></div></body>73 unmodified lines74757677787920 unmodified lines10010110210310410522 unmodified lines12812913013113213313413513613713820 unmodified lines15916016116216316419 unmodified lines18418518618718818919019119219319419517 unmodified lines21321421521621721821973 unmodified linesbackground-color: #fff3e0;color: #ff9800;}.task-instruction {background-color: #f0f8ff;border-left: 5px solid #4CAF50;20 unmodified linesfont-size: 18px;color: #333;}.method-button:hover {opacity: 0.8;}22 unmodified linesbutton:hover {background-color: #45a049;}.error-message {color: red;margin-bottom: 10px;font-size: 18px;}</style><script>function selectMethod(method) {20 unmodified lines}return true;}</script><link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&display=swap" rel="stylesheet"></head>19 unmodified lines</div></div>{% if error %}<div class="error-message">{{ error }}</div>{% endif %}<form id="method-form" action="{{ url_for('index') }}" method="post" onsubmit="return validateForm();"><label for="username">Hi there πππ ! What is your name?</label><input type="text" id="username" name="username" required>17 unmodified lines</div></div><button type="submit">Next</button></form></div></body>
app.py+17-7
templates/index.html+12-9