1 Commits
0.0.2 ... 0.0.3

Author SHA1 Message Date
c14a86b190 Add PWA manifest and SW
All checks were successful
Build & Release / build-docker-image (push) Successful in 1m51s
Build & Release / deploy-to-production (push) Successful in 8s
2026-04-10 21:08:45 +02:00
5 changed files with 41 additions and 0 deletions

View File

@@ -1,12 +1,14 @@
[server]
port = 8501
address = "0.0.0.0"
enableStaticServing = true
[browser]
gatherUsageStats = false
[logger]
level = "info"
hideWelcomeMessage = true
[client]
toolbarMode = "viewer"

21
app/components/pwa.py Normal file
View File

@@ -0,0 +1,21 @@
import streamlit as st
init = st.components.v2.component(
name="pwa",
isolate_styles=False,
js = """
export default function() {
// Manifest
const link = document.createElement("link");
link.rel = "manifest";
link.href = "./app/static/manifest.json";
document.head.appendChild(link);
// Service Worker
navigator.serviceWorker.register('./app/static/service-worker.js')
.then(reg => console.log('SW registered', reg))
.catch(err => console.log('SW registration failed', err));
}
""",
)

8
app/static/manifest.json Normal file
View File

@@ -0,0 +1,8 @@
{
"short_name": "Daily Counter",
"name": "Daily Counter",
"start_url": ".",
"display": "standalone",
"theme_color": "white",
"background_color": "white"
}

View File

@@ -0,0 +1,7 @@
self.addEventListener('fetch', event => {
event.respondWith(
caches.match(event.request).then(response => {
return response || fetch(event.request);
})
);
});

View File

@@ -2,6 +2,9 @@ import streamlit as st
from logger import init_logger
from styles import init_styles
from components import pwa
pwa.init()
init_logger()
init_styles()