haepada commited on
Commit
68dacdb
·
verified ·
1 Parent(s): cbd76b6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -74
app.py CHANGED
@@ -1822,6 +1822,18 @@ def serve_wishes(path):
1822
 
1823
 
1824
  if __name__ == "__main__":
 
 
 
 
 
 
 
 
 
 
 
 
1825
  audio_path = os.path.join('assets', 'main_music.mp3')
1826
  if os.path.exists(audio_path):
1827
  print(f"✅ Audio file found: {audio_path}")
@@ -1829,79 +1841,7 @@ if __name__ == "__main__":
1829
  print(f" Absolute path: {os.path.abspath(audio_path)}")
1830
  else:
1831
  print(f"❌ Audio file not found: {audio_path}")
1832
- sw_content = """
1833
- const CACHE_NAME = 'digital-gutpan-v2';
1834
- const urlsToCache = [
1835
- '/',
1836
- '/assets/main_music.mp3',
1837
- '/static/icons/icon-72x72.png',
1838
- '/static/icons/icon-96x96.png',
1839
- '/static/icons/icon-128x128.png',
1840
- '/static/icons/icon-144x144.png',
1841
- '/static/icons/icon-152x152.png',
1842
- '/static/icons/icon-192x192.png',
1843
- '/static/icons/icon-384x384.png',
1844
- '/static/icons/icon-512x512.png'
1845
- ];
1846
-
1847
- self.addEventListener('install', event => {
1848
- event.waitUntil(
1849
- caches.open(CACHE_NAME)
1850
- .then(cache => {
1851
- console.log('Opened cache');
1852
- return cache.addAll(urlsToCache);
1853
- })
1854
- .then(() => self.skipWaiting())
1855
- );
1856
- });
1857
-
1858
- self.addEventListener('activate', event => {
1859
- event.waitUntil(
1860
- caches.keys().then(cacheNames => {
1861
- return Promise.all(
1862
- cacheNames.map(cacheName => {
1863
- if (cacheName !== CACHE_NAME) {
1864
- return caches.delete(cacheName);
1865
- }
1866
- })
1867
- );
1868
- }).then(() => self.clients.claim())
1869
- );
1870
- });
1871
-
1872
- self.addEventListener('fetch', event => {
1873
- event.respondWith(
1874
- caches.match(event.request)
1875
- .then(response => {
1876
- if (response) {
1877
- return response;
1878
- }
1879
-
1880
- return fetch(event.request).then(
1881
- response => {
1882
- if(!response || response.status !== 200 || response.type !== 'basic') {
1883
- return response;
1884
- }
1885
-
1886
- const responseToCache = response.clone();
1887
-
1888
- caches.open(CACHE_NAME)
1889
- .then(cache => {
1890
- cache.put(event.request, responseToCache);
1891
- });
1892
-
1893
- return response;
1894
- }
1895
- );
1896
- })
1897
- );
1898
- });
1899
- """
1900
-
1901
- # 서비스 워커 파일 생성
1902
- with open('static/service-worker.js', 'w') as f:
1903
- f.write(sw_content)
1904
- create_pwa_files()
1905
  # Gradio 앱 실행
1906
  demo = create_interface()
1907
  demo.queue().launch(
@@ -1911,6 +1851,7 @@ if __name__ == "__main__":
1911
  debug=True,
1912
  show_error=True,
1913
  height=None,
1914
- width="100%"
 
1915
  )
1916
 
 
1822
 
1823
 
1824
  if __name__ == "__main__":
1825
+ # PWA 파일들 생성
1826
+ create_pwa_files()
1827
+
1828
+ # static 디렉토리 생성
1829
+ os.makedirs('static', exist_ok=True)
1830
+
1831
+ # 서비스 워커 파일 생성
1832
+ sw_path = 'static/service-worker.js'
1833
+ with open(sw_path, 'w') as f:
1834
+ f.write(sw_content)
1835
+
1836
+ # 오디오 파일 체크
1837
  audio_path = os.path.join('assets', 'main_music.mp3')
1838
  if os.path.exists(audio_path):
1839
  print(f"✅ Audio file found: {audio_path}")
 
1841
  print(f" Absolute path: {os.path.abspath(audio_path)}")
1842
  else:
1843
  print(f"❌ Audio file not found: {audio_path}")
1844
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1845
  # Gradio 앱 실행
1846
  demo = create_interface()
1847
  demo.queue().launch(
 
1851
  debug=True,
1852
  show_error=True,
1853
  height=None,
1854
+ width="100%",
1855
+ favicon_path="static/icons/icon-72x72.png"
1856
  )
1857