-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.py
More file actions
62 lines (47 loc) · 1.53 KB
/
run.py
File metadata and controls
62 lines (47 loc) · 1.53 KB
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
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/env python3
import socket
import platform
import shutil
import uvicorn
from kiosk.logger import logger
def check_runtime_environment() -> None:
""" Checks that 'heif-convert' is available if running on Linux """
system = platform.system()
if system == 'Linux':
# libheif is required for pillow-heif
if shutil.which('heif-convert') is None:
logger.warning('HEIC requires libheif tools on Linux. '
'(libheif-dev / libheif-tools')
else:
logger.info('HEIC tools detected')
if not any(shutil.which(cmd) for cmd in ('libreoffice', 'soffice')):
logger.warning('Office files requires libreoffice tools')
else:
logger.info('LibreOffice detected')
elif system == 'Windows':
if shutil.which('libreoffice') is None:
logger.warning('Office files requires libreoffice tools')
else:
logger.info('libreOffice detected')
def get_lan_ip() -> str:
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
try:
s.connect(('8.8.8.8', 80))
lan_ip = s.getsockname()[0]
except Exception as e:
logger.error(f'get_lan_ip error: {e}')
lan_ip = '127.0.0.1'
finally:
s.close()
return lan_ip
if __name__ == '__main__':
check_runtime_environment()
ip = get_lan_ip()
port = 8080
logger.info(f'Starting Kiosk server on {ip}:{port}')
uvicorn.run(
'app:app',
host=ip,
port=port,
reload=True
)