Spaces:
Build error
Build error
Commit
Β·
5a5c2f8
1
Parent(s):
56d3d56
update
Browse files- app.py +4 -3
- templates/index.html +0 -15
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
|
| 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
|
| 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
|
| 163 |
return render_template('index.html')
|
| 164 |
|
| 165 |
@app.route('/explanation/<session_id>')
|
|
@@ -358,5 +358,6 @@ def send_visualization(filename):
|
|
| 358 |
def send_examples(filename):
|
| 359 |
return send_from_directory('', filename)
|
| 360 |
|
|
|
|
| 361 |
if __name__ == "__main__":
|
| 362 |
app.run(host="0.0.0.0", port=7860, debug=True)
|
|
|
|
| 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 |
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>')
|
|
|
|
| 358 |
def send_examples(filename):
|
| 359 |
return send_from_directory('', filename)
|
| 360 |
|
| 361 |
+
|
| 362 |
if __name__ == "__main__":
|
| 363 |
app.run(host="0.0.0.0", port=7860, debug=True)
|
templates/index.html
CHANGED
|
@@ -13,15 +13,6 @@
|
|
| 13 |
height: 100vh;
|
| 14 |
margin: 0;
|
| 15 |
}
|
| 16 |
-
.error-message {
|
| 17 |
-
background-color: #ffebee;
|
| 18 |
-
color: #c62828;
|
| 19 |
-
padding: 10px;
|
| 20 |
-
border-radius: 5px;
|
| 21 |
-
margin-bottom: 20px;
|
| 22 |
-
text-align: left;
|
| 23 |
-
font-size: 16px;
|
| 24 |
-
}
|
| 25 |
.container {
|
| 26 |
text-align: center;
|
| 27 |
background-color: #ffffff;
|
|
@@ -196,12 +187,6 @@
|
|
| 196 |
</div>
|
| 197 |
</div>
|
| 198 |
|
| 199 |
-
{% if error %}
|
| 200 |
-
<div class="error-message">
|
| 201 |
-
{{ error }}
|
| 202 |
-
</div>
|
| 203 |
-
{% endif %}
|
| 204 |
-
|
| 205 |
<form id="method-form" action="{{ url_for('index') }}" method="post" onsubmit="return validateForm();">
|
| 206 |
<label for="username">Hi there πππ ! What is your name?</label>
|
| 207 |
<input type="text" id="username" name="username" required>
|
|
|
|
| 13 |
height: 100vh;
|
| 14 |
margin: 0;
|
| 15 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
.container {
|
| 17 |
text-align: center;
|
| 18 |
background-color: #ffffff;
|
|
|
|
| 187 |
</div>
|
| 188 |
</div>
|
| 189 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 190 |
<form id="method-form" action="{{ url_for('index') }}" method="post" onsubmit="return validateForm();">
|
| 191 |
<label for="username">Hi there πππ ! What is your name?</label>
|
| 192 |
<input type="text" id="username" name="username" required>
|