feat: stage vote — QR + 카운터 + autorefresh 3초

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
th-kim0823
2026-04-27 20:08:41 +09:00
parent dd690fcb62
commit 4cd2484374

31
app.py
View File

@@ -17,6 +17,7 @@ from pathlib import Path
import qrcode
import streamlit as st
from streamlit_autorefresh import st_autorefresh
DATA_PATH = os.environ.get(
"DATA_PATH", str(Path(__file__).parent / "hackathon.json")
@@ -446,8 +447,34 @@ def render_stage_topics(data):
def render_stage_vote(data):
st.markdown('<div class="show-stage-title">🗳 투표 시작</div>', unsafe_allow_html=True)
st.info("Task 11에서 구현")
st_autorefresh(interval=3000, key="vote_poll")
st.markdown('<div class="show-stage-title">🗳 투표</div>', unsafe_allow_html=True)
st.markdown(
'<div class="show-stage-sub">📱 휴대폰으로 QR 스캔 → 본인 이름 선택 → 투표</div>',
unsafe_allow_html=True,
)
vote_url = compute_vote_url()
qr_png = make_qr_png(vote_url)
c1, c2, c3 = st.columns([1, 2, 1])
with c2:
st.image(qr_png, use_container_width=False, width=500)
st.markdown(
f'<div class="show-vote-caption">{vote_url}</div>',
unsafe_allow_html=True,
)
votes = data.get("votes", [])
total = len(data.get("people", []))
voted = len(votes)
pct = int(100 * voted / total) if total else 0
st.markdown(
f'<div class="show-vote-counter">{voted} / {total}</div>',
unsafe_allow_html=True,
)
st.progress(pct / 100 if total else 0)
def render_voter():