Spaces:
Runtime error
Runtime error
from collections import Counter | |
from flask import Blueprint | |
from flask import flash | |
from flask import g | |
from flask import redirect | |
from flask import render_template | |
from flask import request | |
from flask import url_for | |
from werkzeug.exceptions import abort | |
from flask import session | |
from threading import Thread | |
from .auth import login_required | |
from .db import get_db | |
from ice_breaking_challenge.google_sheets import get_team_numbers, get_questions_and_answers | |
from ice_breaking_challenge import background_task | |
bp = Blueprint("qr", __name__, url_prefix="/qr") | |
def qr() -> None: | |
match request.method: | |
case "GET": | |
return render_template("qr.html") | |
case "POST": # qr.htmlμμ `λ€μ` λ²νΌ λλ μ λ | |
counter = Counter(get_team_numbers()) | |
if session.get("team_number") not in counter: | |
flash("ν΄λΉ ν λ²νΈκ° μ‘΄μ¬νμ§ μμ΅λλ€.") | |
return render_template("index.html") | |
if counter[session.get("team_number")] == int(session["team_size"]): | |
qna = get_questions_and_answers() | |
Thread(target=background_task, args=(session.sid, qna)).start() | |
import time | |
time.sleep(100) | |
return render_template("introduction.html") | |
else: | |
flash("μ€λ¬Έμ μλ£νμ§ μμ νμμ΄ μμ΅λλ€.") | |
return render_template("qr.html") | |