dongwook-chan's picture
Update
7ff0925
raw
history blame
1.5 kB
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")