-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
daemon_get_pwa.py
52 lines (48 loc) · 1.84 KB
/
daemon_get_pwa.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
__filename__ = "daemon_get_pwa.py"
__author__ = "Bob Mottram"
__license__ = "AGPL3+"
__version__ = "1.6.0"
__maintainer__ = "Bob Mottram"
__email__ = "[email protected]"
__status__ = "Production"
__module_group__ = "Daemon GET"
import json
from httpcodes import write2
from httpheaders import set_headers
from webapp_pwa import pwa_manifest
from utils import convert_domains
from utils import get_json_content_from_accept
from fitnessFunctions import fitness_performance
def progressive_web_app_manifest(self, base_dir: str,
calling_domain: str,
referer_domain: str,
getreq_start_time,
http_prefix: str,
domain: str,
onion_domain: str,
i2p_domain: str,
fitness: {},
debug: bool) -> None:
"""gets the PWA manifest
"""
manifest = pwa_manifest(base_dir)
msg_str = json.dumps(manifest, ensure_ascii=False)
msg_str = convert_domains(calling_domain,
referer_domain,
msg_str,
http_prefix,
domain,
onion_domain,
i2p_domain)
msg = msg_str.encode('utf-8')
msglen = len(msg)
protocol_str = \
get_json_content_from_accept(self.headers['Accept'])
set_headers(self, protocol_str, msglen,
None, calling_domain, False)
write2(self, msg)
if debug:
print('Sent manifest: ' + calling_domain)
fitness_performance(getreq_start_time, fitness,
'_GET', '_progressive_web_app_manifest',
debug)