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") @bp.route("/", methods=["GET", "POST"]) 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")