Browse Source
Merge pull request #1 from technocapeman/main
Added PWA Functionality, Improved Service Worker, Improved Documentation
main
Ravi Shah
5 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with
54 additions and
11 deletions
-
garage_door_script.py
-
static/app.js
-
static/css/bootstrap.min.css
-
static/css/bootstrap.min.css.map
-
static/css/styles.css
-
static/images/android-chrome-192x192.png
-
static/images/android-chrome-512x512.png
-
static/images/apple-touch-icon.png
-
static/images/favicon-16x16.png
-
static/images/favicon-32x32.png
-
static/manifest.json
-
static/service-worker.js
-
templates/index.html
-
templates/login.html
|
|
@ -97,5 +97,11 @@ def favicon(): |
|
|
return send_from_directory(os.path.join(app.root_path, 'static'), |
|
|
return send_from_directory(os.path.join(app.root_path, 'static'), |
|
|
'favicon.ico',mimetype='image/vnd.microsoft.icon') |
|
|
'favicon.ico',mimetype='image/vnd.microsoft.icon') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Route for the Service Worker |
|
|
|
|
|
@app.route('/service-worker.js', methods=['GET']) |
|
|
|
|
|
def sw(): |
|
|
|
|
|
return app.send_static_file('service-worker.js'), 200, {'Content-Type': 'text/javascript'} |
|
|
|
|
|
|
|
|
if __name__ == '__main__': |
|
|
if __name__ == '__main__': |
|
|
app.run(host='0.0.0.0', port=1235) #Run the webserver |
|
|
app.run(host='0.0.0.0', port=1235) #Run the webserver |
|
|
@ -0,0 +1,14 @@ |
|
|
|
|
|
// Credits: https://flaskpwa.com/#_serviceWorkersRegistration
|
|
|
|
|
|
// File Created by [Check Commits for Name]
|
|
|
|
|
|
|
|
|
|
|
|
if ('serviceWorker' in navigator) { |
|
|
|
|
|
navigator.serviceWorker |
|
|
|
|
|
.register('./service-worker.js') |
|
|
|
|
|
.then(function(registration) { |
|
|
|
|
|
console.log('Service Worker Registered!'); |
|
|
|
|
|
return registration; |
|
|
|
|
|
}) |
|
|
|
|
|
.catch(function(err) { |
|
|
|
|
|
console.error('Unable to register service worker.', err); |
|
|
|
|
|
}); |
|
|
|
|
|
} |
Width: 192
|
Height: 192
|
Size: 19 KiB
Width: 192
|
Height: 192
|
Size: 19 KiB
|
Width: 512
|
Height: 512
|
Size: 79 KiB
Width: 512
|
Height: 512
|
Size: 79 KiB
|
Width: 180
|
Height: 180
|
Size: 17 KiB
Width: 180
|
Height: 180
|
Size: 17 KiB
|
Width: 16
|
Height: 16
|
Size: 612 B
Width: 16
|
Height: 16
|
Size: 612 B
|
Width: 32
|
Height: 32
|
Size: 1.5 KiB
Width: 32
|
Height: 32
|
Size: 1.5 KiB
|
|
|
@ -0,0 +1,21 @@ |
|
|
|
|
|
// CREDITS: https://www.pwabuilder.com/serviceworker
|
|
|
|
|
|
// File Created by [Check Commits for Name]
|
|
|
|
|
|
|
|
|
|
|
|
// This is the service worker with the Cache-first network
|
|
|
|
|
|
|
|
|
|
|
|
const CACHE = "pwabuilder-precache"; |
|
|
|
|
|
|
|
|
|
|
|
importScripts('https://storage.googleapis.com/workbox-cdn/releases/5.1.2/workbox-sw.js'); |
|
|
|
|
|
|
|
|
|
|
|
self.addEventListener("message", (event) => { |
|
|
|
|
|
if (event.data && event.data.type === "SKIP_WAITING") { |
|
|
|
|
|
self.skipWaiting(); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
workbox.routing.registerRoute( |
|
|
|
|
|
new RegExp('/'), |
|
|
|
|
|
new workbox.strategies.CacheFirst({ |
|
|
|
|
|
cacheName: CACHE |
|
|
|
|
|
}) |
|
|
|
|
|
); |
|
|
@ -2,12 +2,13 @@ |
|
|
<head> |
|
|
<head> |
|
|
<title>Pi Garage Door Opener</title> |
|
|
<title>Pi Garage Door Opener</title> |
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"> |
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"> |
|
|
<link href="static/bootstrap.min.css" rel="stylesheet" media="screen"> |
|
|
|
|
|
<link href="static/styles.css" rel="stylesheet" media="screen"> |
|
|
|
|
|
<link rel="manifest" href="static/site.webmanifest"> |
|
|
|
|
|
<link rel="apple-touch-icon" sizes="180x180" href="static/apple-touch-icon.png"> |
|
|
|
|
|
<link rel="icon" type="image/png" sizes="32x32" href="static/favicon-32x32.png"> |
|
|
|
|
|
<link rel="icon" type="image/png" sizes="16x16" href="static/favicon-16x16.png"> |
|
|
|
|
|
|
|
|
<link href="{{ url_for('static', filename='css/bootstrap.min.css') }}" rel="stylesheet" media="screen"> |
|
|
|
|
|
<link href="{{ url_for('static', filename='css/styles.css') }}" rel="stylesheet" media="screen"> |
|
|
|
|
|
<link rel="manifest" href="{{ url_for('static', filename='manifest.json') }}"> |
|
|
|
|
|
<link rel="apple-touch-icon" sizes="180x180" href="{{ url_for('static', filename='images/apple-touch-icon.png') }}"> |
|
|
|
|
|
<link rel="icon" type="image/png" sizes="32x32" href="{{ url_for('static', filename='images/favicon-32x32.png') }}"> |
|
|
|
|
|
<link rel="icon" type="image/png" sizes="16x16" href="{{ url_for('static', filename='images/favicon-16x16.png') }}"> |
|
|
|
|
|
<script src="{{ url_for('static', filename='js/app.js') }}"></script> |
|
|
</head> |
|
|
</head> |
|
|
<body> |
|
|
<body> |
|
|
<div class="header"> |
|
|
<div class="header"> |
|
|
|
|
|
@ -2,11 +2,12 @@ |
|
|
<head> |
|
|
<head> |
|
|
<title>Log in to continue</title> |
|
|
<title>Log in to continue</title> |
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"> |
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"> |
|
|
<link href="static/bootstrap.min.css" rel="stylesheet" media="screen"> |
|
|
|
|
|
<link rel="manifest" href="static/site.webmanifest"> |
|
|
|
|
|
<link rel="apple-touch-icon" sizes="180x180" href="static/apple-touch-icon.png"> |
|
|
|
|
|
<link rel="icon" type="image/png" sizes="32x32" href="static/favicon-32x32.png"> |
|
|
|
|
|
<link rel="icon" type="image/png" sizes="16x16" href="static/favicon-16x16.png"> |
|
|
|
|
|
|
|
|
<link href="{{ url_for('static', filename='css/bootstrap.min.css') }}" rel="stylesheet" media="screen"> |
|
|
|
|
|
<link rel="manifest" href="{{ url_for('static', filename='manifest.json') }}"> |
|
|
|
|
|
<link rel="apple-touch-icon" sizes="180x180" href="{{ url_for('static', filename='images/apple-touch-icon.png') }}"> |
|
|
|
|
|
<link rel="icon" type="image/png" sizes="32x32" href="{{ url_for('static', filename='images/favicon-32x32.png') }}"> |
|
|
|
|
|
<link rel="icon" type="image/png" sizes="16x16" href="{{ url_for('static', filename='images/favicon-16x16.png') }}"> |
|
|
|
|
|
<script src="{{ url_for('static', filename='js/app.js') }}"></script> |
|
|
</head> |
|
|
</head> |
|
|
<body> |
|
|
<body> |
|
|
<div class="container"> |
|
|
<div class="container"> |
|
|
|