Updated starter pack

This commit is contained in:
2025-11-28 10:58:38 +03:00
parent cae0d5b946
commit dd33d45f46
16 changed files with 1097 additions and 85 deletions

16
app.py
View File

@@ -1,13 +1,23 @@
from flask import Flask, render_template, request, jsonify, session
import json
import random
from pymongo import MongoClient # Added MongoDB support
# MongoDB connection
MONGO_URI = "mongodb://ai6s3:Student123!@localhost:27017/student_db"
client = MongoClient(MONGO_URI)
db = client.student_db # Connect to student_db database
questions_collection = db.questions # Use questions collection
app = Flask(__name__)
app.secret_key = 'quizimoto_secret_key'
# Load questions from file
with open('questions.json', 'r') as f:
questions_data = json.load(f)
# Load questions from MongoDB
try:
questions_data = list(questions_collection.find({}))
except Exception as e:
print(f"Error loading questions from MongoDB: {e}")
questions_data = [] # Fallback to empty list if database connection fails
# Prize structure (15 levels)
PRIZE_LEVELS = [