Update app.py
Browse files
app.py
CHANGED
@@ -377,16 +377,94 @@ def safe_state_update(state, updates):
|
|
377 |
return state
|
378 |
|
379 |
def create_gradio_interface():
|
380 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
381 |
with gr.Blocks(
|
382 |
theme=gr.themes.Soft(),
|
383 |
css=css,
|
384 |
analytics_enabled=False,
|
385 |
title="디지털 굿판"
|
386 |
) as demo:
|
387 |
-
|
388 |
return demo
|
389 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
390 |
# Gradio 앱 생성
|
391 |
demo = create_gradio_interface()
|
392 |
|
|
|
377 |
return state
|
378 |
|
379 |
def create_gradio_interface():
|
380 |
+
css = """
|
381 |
+
@media (max-width: 600px) {
|
382 |
+
.container { padding: 10px !important; }
|
383 |
+
.gradio-row {
|
384 |
+
flex-direction: column !important;
|
385 |
+
gap: 10px !important;
|
386 |
+
}
|
387 |
+
.gradio-button {
|
388 |
+
width: 100% !important;
|
389 |
+
margin: 5px 0 !important;
|
390 |
+
min-height: 44px !important; /* 모바일 터치 영역 개선 */
|
391 |
+
}
|
392 |
+
.gradio-textbox { width: 100% !important; }
|
393 |
+
.gradio-audio { width: 100% !important; }
|
394 |
+
.gradio-image { width: 100% !important; }
|
395 |
+
#audio-recorder { width: 100% !important; }
|
396 |
+
#result-image { width: 100% !important; }
|
397 |
+
.gradio-dataframe {
|
398 |
+
overflow-x: auto !important;
|
399 |
+
max-width: 100% !important;
|
400 |
+
}
|
401 |
+
.container {
|
402 |
+
padding: 10px !important;
|
403 |
+
overflow-x: hidden !important;
|
404 |
+
}
|
405 |
+
.gradio-row {
|
406 |
+
flex-direction: column !important;
|
407 |
+
gap: 10px !important;
|
408 |
+
}
|
409 |
+
.gradio-button {
|
410 |
+
width: 100% !important;
|
411 |
+
margin: 5px 0 !important;
|
412 |
+
min-height: 44px !important;
|
413 |
+
touch-action: manipulation !important;
|
414 |
+
user-select: none !important;
|
415 |
+
}
|
416 |
+
}
|
417 |
+
|
418 |
+
/* 전반적인 UI 개선 */
|
419 |
+
.gradio-button {
|
420 |
+
transition: all 0.3s ease;
|
421 |
+
}
|
422 |
+
.gradio-button:active {
|
423 |
+
transform: scale(0.98);
|
424 |
+
}
|
425 |
+
|
426 |
+
/* 모바일 최적화 */
|
427 |
+
* {
|
428 |
+
-webkit-tap-highlight-color: transparent;
|
429 |
+
-webkit-touch-callout: none;
|
430 |
+
}
|
431 |
+
|
432 |
+
.record-button {
|
433 |
+
position: relative !important;
|
434 |
+
touch-action: manipulation !important;
|
435 |
+
}
|
436 |
+
"""
|
437 |
+
|
438 |
with gr.Blocks(
|
439 |
theme=gr.themes.Soft(),
|
440 |
css=css,
|
441 |
analytics_enabled=False,
|
442 |
title="디지털 굿판"
|
443 |
) as demo:
|
444 |
+
demo = create_interface()
|
445 |
return demo
|
446 |
|
447 |
+
# 실행 코드 수정
|
448 |
+
if __name__ == "__main__":
|
449 |
+
# 필요한 디렉토리 생성
|
450 |
+
for directory in ['static/icons', 'assets', 'templates', 'data', 'generated_images']:
|
451 |
+
os.makedirs(directory, exist_ok=True)
|
452 |
+
|
453 |
+
# PWA 파일 존재 확인 및 생성 (기존 코드 유지)
|
454 |
+
|
455 |
+
# Gradio 앱 생성
|
456 |
+
demo = create_gradio_interface()
|
457 |
+
|
458 |
+
# Flask 앱에 Gradio 마운트
|
459 |
+
app = gr.mount_gradio_app(app, demo, path="/gradio")
|
460 |
+
|
461 |
+
# Flask 서버 실행
|
462 |
+
app.run(
|
463 |
+
host="0.0.0.0",
|
464 |
+
port=7860,
|
465 |
+
debug=True
|
466 |
+
)
|
467 |
+
|
468 |
# Gradio 앱 생성
|
469 |
demo = create_gradio_interface()
|
470 |
|