luulinh90s commited on
Commit
678720e
·
1 Parent(s): ea1f759
Files changed (2) hide show
  1. app.py +5 -6
  2. templates/index.html +1 -0
app.py CHANGED
@@ -153,6 +153,8 @@ def index():
153
  method = request.form.get('method')
154
  if not username or not seed or not method:
155
  return render_template('index.html', error="Please fill in all fields and select a method.")
 
 
156
  try:
157
  seed = int(seed)
158
  random.seed(seed)
@@ -175,15 +177,12 @@ def index():
175
  save_session_data(session_id, session_data)
176
  logger.info(f"Session data stored for user {username}, method {method}, session_id {session_id}")
177
 
178
- # Redirect based on the selected method
179
- if method == 'No-XAI':
180
- return redirect(url_for('experiment', session_id=session_id))
181
- else:
182
- return redirect(url_for('explanation', session_id=session_id))
183
  except Exception as e:
184
  logger.exception(f"Error in index route: {e}")
185
  return render_template('index.html', error="An error occurred. Please try again.")
186
- return render_template('index.html')
187
 
188
  @app.route('/explanation/<session_id>')
189
  def explanation(session_id):
 
153
  method = request.form.get('method')
154
  if not username or not seed or not method:
155
  return render_template('index.html', error="Please fill in all fields and select a method.")
156
+ if method not in ['Chain-of-Table', 'Plan-of-SQLs', 'Dater']:
157
+ return render_template('index.html', error="Invalid method selected.")
158
  try:
159
  seed = int(seed)
160
  random.seed(seed)
 
177
  save_session_data(session_id, session_data)
178
  logger.info(f"Session data stored for user {username}, method {method}, session_id {session_id}")
179
 
180
+ # Redirect to explanation for all methods
181
+ return redirect(url_for('explanation', session_id=session_id))
 
 
 
182
  except Exception as e:
183
  logger.exception(f"Error in index route: {e}")
184
  return render_template('index.html', error="An error occurred. Please try again.")
185
+ return render_template('index.html', show_no_xai=False)
186
 
187
  @app.route('/explanation/<session_id>')
188
  def explanation(session_id):
templates/index.html CHANGED
@@ -208,6 +208,7 @@
208
  <div class="method-button Dater" onclick="selectMethod('Dater')">
209
  Dater
210
  </div>
 
211
  <div class="method-button No-XAI" onclick="selectMethod('No-XAI')">
212
  No-XAI
213
  </div>
 
208
  <div class="method-button Dater" onclick="selectMethod('Dater')">
209
  Dater
210
  </div>
211
+ {% if show_no_xai %}
212
  <div class="method-button No-XAI" onclick="selectMethod('No-XAI')">
213
  No-XAI
214
  </div>