Update app.py
Browse files
app.py
CHANGED
|
@@ -421,6 +421,108 @@ def create_html_templates(mobile_logo, desktop_logo, main_image):
|
|
| 421 |
"""
|
| 422 |
|
| 423 |
return logo_html, main_image_html, audio_player_html
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 424 |
|
| 425 |
|
| 426 |
# CSS 스타일 정의
|
|
|
|
| 421 |
"""
|
| 422 |
|
| 423 |
return logo_html, main_image_html, audio_player_html
|
| 424 |
+
|
| 425 |
+
def create_pwa_files():
|
| 426 |
+
"""필요한 PWA 파일들을 생성하는 함수"""
|
| 427 |
+
# manifest.json 생성
|
| 428 |
+
manifest_path = 'static/manifest.json'
|
| 429 |
+
manifest_data = {
|
| 430 |
+
"name": "디지털 굿판",
|
| 431 |
+
"short_name": "디지털 굿판",
|
| 432 |
+
"description": "현대 도시 속 디지털 의례 공간",
|
| 433 |
+
"start_url": "/",
|
| 434 |
+
"display": "standalone",
|
| 435 |
+
"background_color": "#ffffff",
|
| 436 |
+
"theme_color": "#000000",
|
| 437 |
+
"orientation": "portrait",
|
| 438 |
+
"icons": [
|
| 439 |
+
{
|
| 440 |
+
"src": "/static/icons/icon-72x72.png",
|
| 441 |
+
"sizes": "72x72",
|
| 442 |
+
"type": "image/png",
|
| 443 |
+
"purpose": "any maskable"
|
| 444 |
+
},
|
| 445 |
+
{
|
| 446 |
+
"src": "/static/icons/icon-96x96.png",
|
| 447 |
+
"sizes": "96x96",
|
| 448 |
+
"type": "image/png",
|
| 449 |
+
"purpose": "any maskable"
|
| 450 |
+
},
|
| 451 |
+
{
|
| 452 |
+
"src": "/static/icons/icon-128x128.png",
|
| 453 |
+
"sizes": "128x128",
|
| 454 |
+
"type": "image/png",
|
| 455 |
+
"purpose": "any maskable"
|
| 456 |
+
},
|
| 457 |
+
{
|
| 458 |
+
"src": "/static/icons/icon-144x144.png",
|
| 459 |
+
"sizes": "144x144",
|
| 460 |
+
"type": "image/png",
|
| 461 |
+
"purpose": "any maskable"
|
| 462 |
+
},
|
| 463 |
+
{
|
| 464 |
+
"src": "/static/icons/icon-192x192.png",
|
| 465 |
+
"sizes": "192x192",
|
| 466 |
+
"type": "image/png",
|
| 467 |
+
"purpose": "any maskable"
|
| 468 |
+
},
|
| 469 |
+
{
|
| 470 |
+
"src": "/static/icons/icon-512x512.png",
|
| 471 |
+
"sizes": "512x512",
|
| 472 |
+
"type": "image/png",
|
| 473 |
+
"purpose": "any maskable"
|
| 474 |
+
}
|
| 475 |
+
]
|
| 476 |
+
}
|
| 477 |
+
os.makedirs('static', exist_ok=True)
|
| 478 |
+
with open(manifest_path, 'w', encoding='utf-8') as f:
|
| 479 |
+
json.dump(manifest_data, f, ensure_ascii=False, indent=2)
|
| 480 |
+
|
| 481 |
+
# service-worker.js 생성
|
| 482 |
+
sw_path = 'static/service-worker.js'
|
| 483 |
+
with open(sw_path, 'w', encoding='utf-8') as f:
|
| 484 |
+
f.write('''
|
| 485 |
+
const CACHE_NAME = 'digital-gutpan-v2';
|
| 486 |
+
const urlsToCache = [
|
| 487 |
+
'/',
|
| 488 |
+
'/assets/main_music.mp3',
|
| 489 |
+
'/static/icons/icon-72x72.png',
|
| 490 |
+
'/static/icons/icon-96x96.png',
|
| 491 |
+
'/static/icons/icon-128x128.png',
|
| 492 |
+
'/static/icons/icon-144x144.png',
|
| 493 |
+
'/static/icons/icon-192x192.png',
|
| 494 |
+
'/static/icons/icon-512x512.png'
|
| 495 |
+
];
|
| 496 |
+
|
| 497 |
+
self.addEventListener('install', event => {
|
| 498 |
+
event.waitUntil(
|
| 499 |
+
caches.open(CACHE_NAME)
|
| 500 |
+
.then(cache => cache.addAll(urlsToCache))
|
| 501 |
+
.then(() => self.skipWaiting())
|
| 502 |
+
);
|
| 503 |
+
});
|
| 504 |
+
|
| 505 |
+
self.addEventListener('activate', event => {
|
| 506 |
+
event.waitUntil(
|
| 507 |
+
caches.keys().then(cacheNames => {
|
| 508 |
+
return Promise.all(
|
| 509 |
+
cacheNames.map(cacheName => {
|
| 510 |
+
if (cacheName !== CACHE_NAME) {
|
| 511 |
+
return caches.delete(cacheName);
|
| 512 |
+
}
|
| 513 |
+
})
|
| 514 |
+
);
|
| 515 |
+
}).then(() => self.clients.claim())
|
| 516 |
+
);
|
| 517 |
+
});
|
| 518 |
+
|
| 519 |
+
self.addEventListener('fetch', event => {
|
| 520 |
+
event.respondWith(
|
| 521 |
+
caches.match(event.request)
|
| 522 |
+
.then(response => response || fetch(event.request))
|
| 523 |
+
);
|
| 524 |
+
});
|
| 525 |
+
'''.strip())
|
| 526 |
|
| 527 |
|
| 528 |
# CSS 스타일 정의
|