luulinh90s commited on
Commit
a3db44b
·
1 Parent(s): 3c6a020
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -135,14 +135,14 @@ def index():
135
  seed = request.form.get('seed')
136
  method = request.form.get('method')
137
  if not username or not seed or not method:
138
- return "Please fill in all fields and select a method.", 400
139
  try:
140
  seed = int(seed)
141
  random.seed(seed)
142
  all_samples = load_samples()
143
  selected_samples = select_balanced_samples(all_samples)
144
  if len(selected_samples) == 0:
145
- return "No common samples were found", 500
146
  start_time = datetime.now().isoformat()
147
  session_id = generate_session_id()
148
  session_data = {
@@ -159,7 +159,7 @@ def index():
159
  return redirect(url_for('explanation', session_id=session_id))
160
  except Exception as e:
161
  logger.exception(f"Error in index route: {e}")
162
- return "An error occurred", 500
163
  return render_template('index.html')
164
 
165
  @app.route('/explanation/<session_id>')
 
135
  seed = request.form.get('seed')
136
  method = request.form.get('method')
137
  if not username or not seed or not method:
138
+ return render_template('index.html', error="Please fill in all fields and select a method.")
139
  try:
140
  seed = int(seed)
141
  random.seed(seed)
142
  all_samples = load_samples()
143
  selected_samples = select_balanced_samples(all_samples)
144
  if len(selected_samples) == 0:
145
+ return render_template('index.html', error="No common samples were found")
146
  start_time = datetime.now().isoformat()
147
  session_id = generate_session_id()
148
  session_data = {
 
159
  return redirect(url_for('explanation', session_id=session_id))
160
  except Exception as e:
161
  logger.exception(f"Error in index route: {e}")
162
+ return render_template('index.html', error="An error occurred. Please try again.")
163
  return render_template('index.html')
164
 
165
  @app.route('/explanation/<session_id>')