convert to pwa app
This commit is contained in:
parent
d718b89035
commit
e1d48bf7de
5
app.py
5
app.py
@ -1,5 +1,5 @@
|
||||
# app.py
|
||||
from flask import Flask, render_template, request, redirect, url_for, session, flash
|
||||
from flask import Flask, render_template, request, redirect, url_for, session, flash, send_file
|
||||
from flask_caching import Cache
|
||||
import requests.auth
|
||||
import os
|
||||
@ -17,6 +17,9 @@ app.config.from_object(
|
||||
)
|
||||
cache = Cache(app, config={"CACHE_TYPE": "SimpleCache"})
|
||||
|
||||
@app.route('/manifest.json')
|
||||
def serve_manifest():
|
||||
return send_file('manifest.json', mimetype='application/manifest+json')
|
||||
|
||||
@app.route("/favicon.ico")
|
||||
def favicon():
|
||||
|
BIN
static/icons/android-launchericon-144-144.png
Normal file
BIN
static/icons/android-launchericon-144-144.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.1 KiB |
BIN
static/icons/android-launchericon-192-192.png
Normal file
BIN
static/icons/android-launchericon-192-192.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.2 KiB |
BIN
static/icons/android-launchericon-512-512.png
Normal file
BIN
static/icons/android-launchericon-512-512.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 24 KiB |
29
static/manifest.json
Normal file
29
static/manifest.json
Normal file
@ -0,0 +1,29 @@
|
||||
{
|
||||
"name": "KTVManager",
|
||||
"short_name": "KTV",
|
||||
"start_url": "https://tv-ui.k-world.me.uk/",
|
||||
"scope": "/",
|
||||
"display": "standalone",
|
||||
"theme_color": "#317EFB",
|
||||
"background_color": "#317EFB",
|
||||
"icons": [
|
||||
{
|
||||
"src": "/static/icons/android-launchericon-144-144.png",
|
||||
"sizes": "144x144",
|
||||
"type": "image/png",
|
||||
"purpose": "any maskable"
|
||||
},
|
||||
{
|
||||
"src": "/static/icons/android-launchericon-192-192.png",
|
||||
"sizes": "192x192",
|
||||
"type": "image/png",
|
||||
"purpose": "any maskable"
|
||||
},
|
||||
{
|
||||
"src": "/static/icons/android-launchericon-512-512.png",
|
||||
"sizes": "512x512",
|
||||
"type": "image/png",
|
||||
"purpose": "any maskable"
|
||||
}
|
||||
]
|
||||
}
|
22
static/service-worker.js
Normal file
22
static/service-worker.js
Normal file
@ -0,0 +1,22 @@
|
||||
self.addEventListener('install', function (event) {
|
||||
event.waitUntil(
|
||||
caches.open('my-cache').then(function (cache) {
|
||||
return cache.addAll([
|
||||
'/',
|
||||
'/index.html',
|
||||
'/static/styles.css',
|
||||
'/static/script.js',
|
||||
'/static/icons/icon-192x192.png',
|
||||
'/static/icons/icon-512x512.png'
|
||||
]);
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
self.addEventListener('fetch', function (event) {
|
||||
event.respondWith(
|
||||
caches.match(event.request).then(function (response) {
|
||||
return response || fetch(event.request);
|
||||
})
|
||||
);
|
||||
});
|
@ -6,6 +6,7 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>KTV Manager</title>
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
|
||||
<link rel="manifest" href="{{ url_for('static', filename='manifest.json') }}">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
@ -58,5 +59,19 @@
|
||||
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.0.7/dist/umd/popper.min.js"></script>
|
||||
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
|
||||
<script>
|
||||
if ('serviceWorker' in navigator) {
|
||||
window.addEventListener('load', function() {
|
||||
navigator.serviceWorker.register("{{ url_for('static', filename='service-worker.js') }}")
|
||||
.then(function(registration) {
|
||||
console.log('Service Worker registered with scope: ', registration.scope);
|
||||
})
|
||||
.catch(function(error) {
|
||||
console.log('Service Worker registration failed: ', error);
|
||||
});
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
Loading…
x
Reference in New Issue
Block a user