Update app.py
Browse files
app.py
CHANGED
|
@@ -44,6 +44,10 @@ load_dotenv()
|
|
| 44 |
def serve_static(path):
|
| 45 |
return send_from_directory('static', path)
|
| 46 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
@app.route('/assets/<path:path>')
|
| 48 |
def serve_assets(path):
|
| 49 |
try:
|
|
@@ -529,6 +533,61 @@ self.addEventListener('fetch', event => {
|
|
| 529 |
<meta name="apple-mobile-web-app-status-bar-style" content="black">
|
| 530 |
<meta name="apple-mobile-web-app-title" content="디지털 굿판">
|
| 531 |
<link rel="apple-touch-icon" href="/static/icons/icon-152x152.png">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 532 |
<script>
|
| 533 |
// 화면 꺼짐 방지
|
| 534 |
async function preventSleep() {
|
|
@@ -563,7 +622,9 @@ self.addEventListener('fetch', event => {
|
|
| 563 |
</script>
|
| 564 |
</head>
|
| 565 |
<body>
|
|
|
|
| 566 |
<div id="gradio-app"></div>
|
|
|
|
| 567 |
</body>
|
| 568 |
</html>''')
|
| 569 |
|
|
@@ -808,6 +869,61 @@ def create_interface():
|
|
| 808 |
color: #4a90e2 !important;
|
| 809 |
}
|
| 810 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 811 |
"""
|
| 812 |
|
| 813 |
with gr.Blocks(theme=gr.themes.Soft(), css=css) as app:
|
|
|
|
| 44 |
def serve_static(path):
|
| 45 |
return send_from_directory('static', path)
|
| 46 |
|
| 47 |
+
@app.route('/')
|
| 48 |
+
def index():
|
| 49 |
+
return render_template('index.html')
|
| 50 |
+
|
| 51 |
@app.route('/assets/<path:path>')
|
| 52 |
def serve_assets(path):
|
| 53 |
try:
|
|
|
|
| 533 |
<meta name="apple-mobile-web-app-status-bar-style" content="black">
|
| 534 |
<meta name="apple-mobile-web-app-title" content="디지털 굿판">
|
| 535 |
<link rel="apple-touch-icon" href="/static/icons/icon-152x152.png">
|
| 536 |
+
<style>
|
| 537 |
+
/* iOS 상태바 영역 보호 */
|
| 538 |
+
body {
|
| 539 |
+
padding-top: env(safe-area-inset-top);
|
| 540 |
+
}
|
| 541 |
+
.status-bar {
|
| 542 |
+
position: fixed;
|
| 543 |
+
top: 0;
|
| 544 |
+
left: 0;
|
| 545 |
+
right: 0;
|
| 546 |
+
height: env(safe-area-inset-top);
|
| 547 |
+
background: black;
|
| 548 |
+
z-index: 1000;
|
| 549 |
+
}
|
| 550 |
+
</style>
|
| 551 |
+
<script>
|
| 552 |
+
// 페이지 로드 시 상단으로 스크롤
|
| 553 |
+
window.addEventListener('load', function() {
|
| 554 |
+
// 약간의 지연을 주어 컨텐츠가 모두 로드된 후 스크롤
|
| 555 |
+
setTimeout(() => {
|
| 556 |
+
window.scrollTo(0, 0);
|
| 557 |
+
}, 100);
|
| 558 |
+
});
|
| 559 |
+
|
| 560 |
+
// 화면 꺼짐 방지
|
| 561 |
+
async function preventSleep() {
|
| 562 |
+
try {
|
| 563 |
+
if ('wakeLock' in navigator) {
|
| 564 |
+
const wakeLock = await navigator.wakeLock.request('screen');
|
| 565 |
+
console.log('화면 켜짐 유지 활성화');
|
| 566 |
+
|
| 567 |
+
document.addEventListener('visibilitychange', async () => {
|
| 568 |
+
if (document.visibilityState === 'visible') {
|
| 569 |
+
await preventSleep();
|
| 570 |
+
}
|
| 571 |
+
});
|
| 572 |
+
}
|
| 573 |
+
} catch (err) {
|
| 574 |
+
console.log('화면 켜짐 유지 실패:', err);
|
| 575 |
+
}
|
| 576 |
+
}
|
| 577 |
+
|
| 578 |
+
// PWA 설치 관련
|
| 579 |
+
if ('serviceWorker' in navigator) {
|
| 580 |
+
window.addEventListener('load', async () => {
|
| 581 |
+
try {
|
| 582 |
+
const registration = await navigator.serviceWorker.register('/service-worker.js');
|
| 583 |
+
console.log('ServiceWorker 등록 성공:', registration.scope);
|
| 584 |
+
await preventSleep();
|
| 585 |
+
} catch (err) {
|
| 586 |
+
console.log('ServiceWorker 등록 실패:', err);
|
| 587 |
+
}
|
| 588 |
+
});
|
| 589 |
+
}
|
| 590 |
+
</script>
|
| 591 |
<script>
|
| 592 |
// 화면 꺼짐 방지
|
| 593 |
async function preventSleep() {
|
|
|
|
| 622 |
</script>
|
| 623 |
</head>
|
| 624 |
<body>
|
| 625 |
+
<div class="status-bar"></div>
|
| 626 |
<div id="gradio-app"></div>
|
| 627 |
+
<div class="footer-spacing"></div>
|
| 628 |
</body>
|
| 629 |
</html>''')
|
| 630 |
|
|
|
|
| 869 |
color: #4a90e2 !important;
|
| 870 |
}
|
| 871 |
}
|
| 872 |
+
/* Hugging Face 로고 숨기기 */
|
| 873 |
+
div.gr-header {
|
| 874 |
+
display: none !important;
|
| 875 |
+
}
|
| 876 |
+
|
| 877 |
+
/* 앱 스타일 컨테이너 */
|
| 878 |
+
body {
|
| 879 |
+
margin: 0;
|
| 880 |
+
padding: 0;
|
| 881 |
+
background: #f5f5f5;
|
| 882 |
+
overflow-x: hidden;
|
| 883 |
+
position: relative;
|
| 884 |
+
min-height: 100vh;
|
| 885 |
+
}
|
| 886 |
+
|
| 887 |
+
/* 메인 컨테이너 스타일링 */
|
| 888 |
+
.gradio-container {
|
| 889 |
+
margin: 0 auto !important;
|
| 890 |
+
padding: 0 !important;
|
| 891 |
+
max-width: 800px !important;
|
| 892 |
+
background: white;
|
| 893 |
+
min-height: 100vh;
|
| 894 |
+
box-shadow: 0 0 10px rgba(0,0,0,0.1);
|
| 895 |
+
position: relative;
|
| 896 |
+
}
|
| 897 |
+
|
| 898 |
+
/* 상단 상태바 스타일 */
|
| 899 |
+
.status-bar {
|
| 900 |
+
position: fixed;
|
| 901 |
+
top: 0;
|
| 902 |
+
left: 0;
|
| 903 |
+
right: 0;
|
| 904 |
+
height: env(safe-area-inset-top);
|
| 905 |
+
background: black;
|
| 906 |
+
z-index: 1000;
|
| 907 |
+
}
|
| 908 |
+
|
| 909 |
+
/* 하단 여백 조정 */
|
| 910 |
+
.footer-spacing {
|
| 911 |
+
height: env(safe-area-inset-bottom);
|
| 912 |
+
background: white;
|
| 913 |
+
}
|
| 914 |
+
|
| 915 |
+
/* 앱 스크롤 동작 */
|
| 916 |
+
.app-scroll {
|
| 917 |
+
-webkit-overflow-scrolling: touch;
|
| 918 |
+
scroll-behavior: smooth;
|
| 919 |
+
}
|
| 920 |
+
|
| 921 |
+
/* 모바일 Safari에서 고정 요소들의 위치 조정 */
|
| 922 |
+
@supports (-webkit-touch-callout: none) {
|
| 923 |
+
.status-bar {
|
| 924 |
+
height: max(env(safe-area-inset-top), 20px);
|
| 925 |
+
}
|
| 926 |
+
}
|
| 927 |
"""
|
| 928 |
|
| 929 |
with gr.Blocks(theme=gr.themes.Soft(), css=css) as app:
|