Fausto Busuito commited on
Commit
4556c83
1 Parent(s): 45d7462

Application changes

Browse files
Files changed (2) hide show
  1. app.py +8 -7
  2. requirements.txt +2 -1
app.py CHANGED
@@ -1,4 +1,5 @@
1
  from flask import Flask, render_template, request, redirect, url_for, session
 
2
  import json
3
  import random
4
  import os
@@ -6,6 +7,10 @@ import os
6
  app = Flask(__name__)
7
  app.secret_key = 'supersecretkey'
8
 
 
 
 
 
9
  QUESTIONS_FOLDER = 'questions'
10
 
11
  @app.route('/')
@@ -45,13 +50,9 @@ def quiz():
45
  if session['current_question'] >= len(session['questions']):
46
  return redirect(url_for('results'))
47
 
48
- # Ensure current_question is within the valid range
49
- if session['current_question'] < len(session['questions']):
50
- return render_template('quiz.html', question=session['questions'][session['current_question']],
51
- question_number=session['current_question'] + 1,
52
- total_questions=len(session['questions']))
53
- else:
54
- return redirect(url_for('results'))
55
 
56
  @app.route('/results')
57
  def results():
 
1
  from flask import Flask, render_template, request, redirect, url_for, session
2
+ from flask_session import Session
3
  import json
4
  import random
5
  import os
 
7
  app = Flask(__name__)
8
  app.secret_key = 'supersecretkey'
9
 
10
+ # Configure Flask-Session
11
+ app.config['SESSION_TYPE'] = 'filesystem'
12
+ Session(app)
13
+
14
  QUESTIONS_FOLDER = 'questions'
15
 
16
  @app.route('/')
 
50
  if session['current_question'] >= len(session['questions']):
51
  return redirect(url_for('results'))
52
 
53
+ return render_template('quiz.html', question=session['questions'][session['current_question']],
54
+ question_number=session['current_question'] + 1,
55
+ total_questions=len(session['questions']))
 
 
 
 
56
 
57
  @app.route('/results')
58
  def results():
requirements.txt CHANGED
@@ -1 +1,2 @@
1
- Flask
 
 
1
+ Flask
2
+ Flask-Session