luulinh90s
commited on
Commit
·
2529cfa
1
Parent(s):
5a5c2f8
update
Browse files
app.py
CHANGED
@@ -128,6 +128,7 @@ def introduction():
|
|
128 |
def attribution():
|
129 |
return render_template('attribution.html')
|
130 |
|
|
|
131 |
@app.route('/index', methods=['GET', 'POST'])
|
132 |
def index():
|
133 |
if request.method == 'POST':
|
@@ -135,14 +136,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."
|
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"
|
146 |
start_time = datetime.now().isoformat()
|
147 |
session_id = generate_session_id()
|
148 |
session_data = {
|
@@ -159,9 +160,11 @@ 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"
|
163 |
return render_template('index.html')
|
164 |
|
|
|
|
|
165 |
@app.route('/explanation/<session_id>')
|
166 |
def explanation(session_id):
|
167 |
session_data = session.get('data')
|
|
|
128 |
def attribution():
|
129 |
return render_template('attribution.html')
|
130 |
|
131 |
+
|
132 |
@app.route('/index', methods=['GET', 'POST'])
|
133 |
def index():
|
134 |
if request.method == 'POST':
|
|
|
136 |
seed = request.form.get('seed')
|
137 |
method = request.form.get('method')
|
138 |
if not username or not seed or not method:
|
139 |
+
return render_template('index.html', error="Please fill in all fields and select a method.")
|
140 |
try:
|
141 |
seed = int(seed)
|
142 |
random.seed(seed)
|
143 |
all_samples = load_samples()
|
144 |
selected_samples = select_balanced_samples(all_samples)
|
145 |
if len(selected_samples) == 0:
|
146 |
+
return render_template('index.html', error="No common samples were found")
|
147 |
start_time = datetime.now().isoformat()
|
148 |
session_id = generate_session_id()
|
149 |
session_data = {
|
|
|
160 |
return redirect(url_for('explanation', session_id=session_id))
|
161 |
except Exception as e:
|
162 |
logger.exception(f"Error in index route: {e}")
|
163 |
+
return render_template('index.html', error="An error occurred. Please try again.")
|
164 |
return render_template('index.html')
|
165 |
|
166 |
+
|
167 |
+
|
168 |
@app.route('/explanation/<session_id>')
|
169 |
def explanation(session_id):
|
170 |
session_data = session.get('data')
|