feat: admin URL 쉽게 접근 - show-urls.sh + admin 내부 링크

- show-urls.sh: localhost + LAN IP 포함 모든 URL 출력 (참가자/어드민/시상식)
- admin 페이지에 다른 페이지 URL expander 추가 (ceremony 링크 클릭 가능)
- README에 사용법 추가

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
th-kim0823
2026-04-26 18:35:15 +09:00
parent 6e517be918
commit 067e25116a
3 changed files with 60 additions and 0 deletions

View File

@@ -30,10 +30,20 @@ docker compose down
## URL
```bash
./show-urls.sh # localhost + LAN IP 포함 모든 URL 출력
```
- 투표: `http://<서버>:8501/`
- 어드민: `http://<서버>:8501/?mode=admin&token=<TOKEN>`
- 시상식: `http://<서버>:8501/?mode=ceremony&token=<TOKEN>`
macOS 빠른 열기:
```bash
TOKEN=$(grep ADMIN_TOKEN .env | cut -d= -f2)
open "http://localhost:8501/?mode=admin&token=${TOKEN}"
```
## 데이터 파일 — `hackathon.json`
```json

13
app.py
View File

@@ -355,6 +355,19 @@ def render_admin():
st.title("🔐 진행자 콘솔")
with st.expander("🔗 다른 페이지 URL"):
st.markdown(
f"""
- 👥 **참가자 투표**: [/](/)
- 🎉 **시상식 (큰 화면)**: [/?mode=ceremony&token=...](?mode=ceremony&token={ADMIN_TOKEN})
호스트에서 LAN IP 포함 모든 URL 보기:
```bash
./show-urls.sh
```
"""
)
voting_open = is_voting_open()
cur_label = "🟢 투표 진행 중" if voting_open else "🔴 투표 마감됨"
st.markdown(f"### 투표 상태: {cur_label}")

37
show-urls.sh Executable file
View File

@@ -0,0 +1,37 @@
#!/bin/bash
# 해커톤 투표 URL 출력 (호스트에서 실행)
set -euo pipefail
cd "$(dirname "$0")"
if [[ ! -f .env ]]; then
echo "❌ .env 파일 없음. 먼저 'cp .env.example .env' 후 ADMIN_TOKEN 설정."
exit 1
fi
TOKEN=$(grep -E "^ADMIN_TOKEN=" .env | head -1 | cut -d= -f2- | tr -d '"')
PORT=$(grep -E "^PORT=" .env 2>/dev/null | head -1 | cut -d= -f2- | tr -d '"' || echo "")
PORT=${PORT:-8501}
# LAN IP 자동 감지 (macOS/Linux)
LAN_IP=$(ipconfig getifaddr en0 2>/dev/null || ip -4 addr show 2>/dev/null | grep -oP '(?<=inet\s)\d+(\.\d+){3}' | grep -v '^127\.' | head -1 || echo "")
echo "============================================"
echo " 해커톤 투표 URL"
echo "============================================"
echo
echo "👥 참가자 투표:"
echo " http://localhost:${PORT}/"
[[ -n "$LAN_IP" ]] && echo " http://${LAN_IP}:${PORT}/ (LAN)"
echo
echo "🔐 진행자 어드민:"
echo " http://localhost:${PORT}/?mode=admin&token=${TOKEN}"
[[ -n "$LAN_IP" ]] && echo " http://${LAN_IP}:${PORT}/?mode=admin&token=${TOKEN}"
echo
echo "🎉 시상식 (큰 화면):"
echo " http://localhost:${PORT}/?mode=ceremony&token=${TOKEN}"
[[ -n "$LAN_IP" ]] && echo " http://${LAN_IP}:${PORT}/?mode=ceremony&token=${TOKEN}"
echo
echo "============================================"
echo " 팁: 'open' 으로 바로 브라우저 열기 (macOS)"
echo " open \"http://localhost:${PORT}/?mode=admin&token=${TOKEN}\""
echo "============================================"