haepada commited on
Commit
90b9d37
·
verified ·
1 Parent(s): 3ed65ad

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -52
app.py CHANGED
@@ -9,6 +9,8 @@ from transformers import pipeline
9
  import requests
10
  from dotenv import load_dotenv
11
 
 
 
12
  # 상수 정의
13
  WELCOME_MESSAGE = """
14
  # 디지털 굿판에 오신 것을 환영합니다
@@ -1796,7 +1798,6 @@ def create_interface():
1796
  return app
1797
 
1798
 
1799
- # Flask 라우트
1800
  @app.route('/static/<path:path>')
1801
  def serve_static(path):
1802
  return send_from_directory('static', path)
@@ -1805,23 +1806,28 @@ def serve_static(path):
1805
  def index():
1806
  return render_template('index.html')
1807
 
1808
- @app.route('/static/<path:path>')
1809
  @app.route('/assets/<path:path>')
 
 
 
1810
  @app.route('/manifest.json')
 
 
 
1811
  @app.route('/service-worker.js')
1812
-
 
 
1813
  @app.route('/wishes/<path:path>')
1814
  def serve_wishes(path):
1815
  return send_from_directory('data/wishes', path)
1816
 
1817
- os.makedirs("generated_images", exist_ok=True)
1818
- os.makedirs('static', exist_ok=True)
1819
- os.makedirs('assets', exist_ok=True)
1820
-
1821
 
1822
  if __name__ == "__main__":
1823
  # 환경변수 로드
1824
  load_dotenv()
 
 
1825
  required_dirs = [
1826
  'static',
1827
  'assets',
@@ -1844,50 +1850,9 @@ if __name__ == "__main__":
1844
  else:
1845
  print(f"❌ Audio file not found: {audio_path}")
1846
 
1847
- # Gradio 앱만 실행
1848
  demo = create_interface()
1849
- demo.queue().launch(
1850
- server_name="0.0.0.0",
1851
- server_port=7860,
1852
- share=True,
1853
- debug=True,
1854
- show_error=True,
1855
- height=None,
1856
- width="100%",
1857
- favicon_path="static/icons/icon-72x72.png",
1858
-
1859
- # PWA 관련 헤더와 메타 데이터
1860
- head="""
1861
- <link rel="manifest" href="/static/manifest.json">
1862
- <meta name="theme-color" content="#0b0f19">
1863
- <meta name="apple-mobile-web-app-capable" content="yes">
1864
- <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
1865
- <meta name="apple-mobile-web-app-title" content="디지털 굿판">
1866
- """
1867
- )
1868
- custom_html = """
1869
- <!DOCTYPE html>
1870
- <html lang="ko">
1871
- <head>
1872
- <meta charset="utf-8">
1873
- <meta name="viewport" content="width=device-width, initial-scale=1">
1874
- <title>디지털 굿판</title>
1875
- <link rel="manifest" href="/static/manifest.json">
1876
- <meta name="theme-color" content="#0b0f19">
1877
- <meta name="apple-mobile-web-app-capable" content="yes">
1878
- <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
1879
- <meta name="apple-mobile-web-app-title" content="디지털 굿판">
1880
- {%css%}
1881
- </head>
1882
- <body>
1883
- <div id="gradio-app">
1884
- {%body%}
1885
- </div>
1886
- {%scripts%}
1887
- </body>
1888
- </html>
1889
- """
1890
-
1891
  # Gradio 앱 실행
1892
  demo.queue().launch(
1893
  server_name="0.0.0.0",
@@ -1897,6 +1862,5 @@ if __name__ == "__main__":
1897
  show_error=True,
1898
  height=None,
1899
  width="100%",
1900
- favicon_path="static/icons/icon-72x72.png",
1901
- custom_html=custom_html
1902
  )
 
9
  import requests
10
  from dotenv import load_dotenv
11
 
12
+ app = Flask(__name__)
13
+
14
  # 상수 정의
15
  WELCOME_MESSAGE = """
16
  # 디지털 굿판에 오신 것을 환영합니다
 
1798
  return app
1799
 
1800
 
 
1801
  @app.route('/static/<path:path>')
1802
  def serve_static(path):
1803
  return send_from_directory('static', path)
 
1806
  def index():
1807
  return render_template('index.html')
1808
 
 
1809
  @app.route('/assets/<path:path>')
1810
+ def serve_assets(path):
1811
+ return send_from_directory('assets', path)
1812
+
1813
  @app.route('/manifest.json')
1814
+ def serve_manifest():
1815
+ return send_from_directory('static', 'manifest.json')
1816
+
1817
  @app.route('/service-worker.js')
1818
+ def serve_service_worker():
1819
+ return send_from_directory('static', 'service-worker.js')
1820
+
1821
  @app.route('/wishes/<path:path>')
1822
  def serve_wishes(path):
1823
  return send_from_directory('data/wishes', path)
1824
 
 
 
 
 
1825
 
1826
  if __name__ == "__main__":
1827
  # 환경변수 로드
1828
  load_dotenv()
1829
+
1830
+ # 필요한 디렉토리 생성
1831
  required_dirs = [
1832
  'static',
1833
  'assets',
 
1850
  else:
1851
  print(f"❌ Audio file not found: {audio_path}")
1852
 
1853
+ # Gradio 인터페이스 생성
1854
  demo = create_interface()
1855
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1856
  # Gradio 앱 실행
1857
  demo.queue().launch(
1858
  server_name="0.0.0.0",
 
1862
  show_error=True,
1863
  height=None,
1864
  width="100%",
1865
+ favicon_path="static/icons/icon-72x72.png"
 
1866
  )