haepada commited on
Commit
9069bef
·
verified ·
1 Parent(s): b043329

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +38 -0
app.py CHANGED
@@ -4,10 +4,22 @@ import librosa
4
  from transformers import pipeline
5
  from datetime import datetime
6
  import os
 
7
  import requests
8
  import json
9
  from dotenv import load_dotenv
10
 
 
 
 
 
 
 
 
 
 
 
 
11
  # 환경변수 로드
12
  load_dotenv()
13
 
@@ -363,6 +375,25 @@ def safe_state_update(state, updates):
363
  except Exception as e:
364
  print(f"State update error: {e}")
365
  return state
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
366
 
367
  def create_interface():
368
  db = SimpleDB()
@@ -763,6 +794,8 @@ def create_interface():
763
  return app
764
 
765
  if __name__ == "__main__":
 
 
766
  demo = create_interface()
767
  demo.launch(
768
  debug=True,
@@ -772,4 +805,9 @@ if __name__ == "__main__":
772
  show_error=True,
773
  height=None,
774
  width="100%"
 
 
 
 
 
775
  )
 
4
  from transformers import pipeline
5
  from datetime import datetime
6
  import os
7
+ from flask import Flask, send_from_directory, render_template
8
  import requests
9
  import json
10
  from dotenv import load_dotenv
11
 
12
+ app = Flask(__name__)
13
+
14
+ # PWA 관련 라우트
15
+ @app.route('/static/<path:path>')
16
+ def serve_static(path):
17
+ return send_from_directory('static', path)
18
+
19
+ @app.route('/assets/<path:path>')
20
+ def serve_assets(path):
21
+ return send_from_directory('assets', path)
22
+
23
  # 환경변수 로드
24
  load_dotenv()
25
 
 
375
  except Exception as e:
376
  print(f"State update error: {e}")
377
  return state
378
+
379
+ def create_gradio_interface():
380
+ # ... (기존 Gradio 인터페이스 코드)
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
+
393
+ # Gradio 앱을 Flask에 마운트
394
+ app = gr.mount_gradio_app(app, demo, path="/")
395
+
396
+
397
 
398
  def create_interface():
399
  db = SimpleDB()
 
794
  return app
795
 
796
  if __name__ == "__main__":
797
+ os.makedirs("static/icons", exist_ok=True)
798
+ os.makedirs("assets", exist_ok=True)
799
  demo = create_interface()
800
  demo.launch(
801
  debug=True,
 
805
  show_error=True,
806
  height=None,
807
  width="100%"
808
+ # 서버 실행
809
+ app.run(
810
+ host="0.0.0.0",
811
+ port=7860,
812
+ debug=True
813
  )