Commit
·
09a6458
1
Parent(s):
7003a4e
update
Browse files
app.py
CHANGED
|
@@ -68,6 +68,7 @@ def select_balanced_samples(samples):
|
|
| 68 |
def generate_random_string(length=8):
|
| 69 |
return ''.join(random.choices(string.ascii_letters + string.digits, k=length))
|
| 70 |
|
|
|
|
| 71 |
@app.route('/', methods=['GET', 'POST'])
|
| 72 |
def index():
|
| 73 |
logger.info("Rendering index page.")
|
|
@@ -101,7 +102,6 @@ def index():
|
|
| 101 |
|
| 102 |
session['responses'] = [] # Initialize responses list
|
| 103 |
session['method'] = method # Store the selected method
|
| 104 |
-
logger.info(f"Method stored in session: {session['method']}")
|
| 105 |
|
| 106 |
return redirect(url_for('experiment', username=username, sample_index=0, seed=seed, filename=filename))
|
| 107 |
except Exception as e:
|
|
@@ -118,10 +118,7 @@ def experiment(username, sample_index, seed, filename):
|
|
| 118 |
with open(f'session_data/{filename}', 'r') as f:
|
| 119 |
selected_samples = json.load(f)
|
| 120 |
|
| 121 |
-
method = session.get('method')
|
| 122 |
-
if not method:
|
| 123 |
-
logger.error(f"Method not found in session. Session contents: {session.items()}")
|
| 124 |
-
return "Method not found", 500
|
| 125 |
|
| 126 |
if sample_index >= len(selected_samples):
|
| 127 |
logger.error(f"Sample index {sample_index} exceeds the number of selected samples {len(selected_samples)}.")
|
|
|
|
| 68 |
def generate_random_string(length=8):
|
| 69 |
return ''.join(random.choices(string.ascii_letters + string.digits, k=length))
|
| 70 |
|
| 71 |
+
|
| 72 |
@app.route('/', methods=['GET', 'POST'])
|
| 73 |
def index():
|
| 74 |
logger.info("Rendering index page.")
|
|
|
|
| 102 |
|
| 103 |
session['responses'] = [] # Initialize responses list
|
| 104 |
session['method'] = method # Store the selected method
|
|
|
|
| 105 |
|
| 106 |
return redirect(url_for('experiment', username=username, sample_index=0, seed=seed, filename=filename))
|
| 107 |
except Exception as e:
|
|
|
|
| 118 |
with open(f'session_data/{filename}', 'r') as f:
|
| 119 |
selected_samples = json.load(f)
|
| 120 |
|
| 121 |
+
method = session.get('method') # Retrieve the selected method
|
|
|
|
|
|
|
|
|
|
| 122 |
|
| 123 |
if sample_index >= len(selected_samples):
|
| 124 |
logger.error(f"Sample index {sample_index} exceeds the number of selected samples {len(selected_samples)}.")
|