feat: stage vote — QR + 카운터 + autorefresh 3초
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
31
app.py
31
app.py
@@ -17,6 +17,7 @@ from pathlib import Path
|
|||||||
|
|
||||||
import qrcode
|
import qrcode
|
||||||
import streamlit as st
|
import streamlit as st
|
||||||
|
from streamlit_autorefresh import st_autorefresh
|
||||||
|
|
||||||
DATA_PATH = os.environ.get(
|
DATA_PATH = os.environ.get(
|
||||||
"DATA_PATH", str(Path(__file__).parent / "hackathon.json")
|
"DATA_PATH", str(Path(__file__).parent / "hackathon.json")
|
||||||
@@ -446,8 +447,34 @@ def render_stage_topics(data):
|
|||||||
|
|
||||||
|
|
||||||
def render_stage_vote(data):
|
def render_stage_vote(data):
|
||||||
st.markdown('<div class="show-stage-title">🗳 투표 시작</div>', unsafe_allow_html=True)
|
st_autorefresh(interval=3000, key="vote_poll")
|
||||||
st.info("Task 11에서 구현")
|
|
||||||
|
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():
|
def render_voter():
|
||||||
|
|||||||
Reference in New Issue
Block a user