diff --git a/display_images/Crypto.ppm b/display_images/Crypto.ppm index fc72427..ecc1327 100755 Binary files a/display_images/Crypto.ppm and b/display_images/Crypto.ppm differ diff --git a/log.txt b/log.txt index 72cbb6b..e69de29 100755 --- a/log.txt +++ b/log.txt @@ -1,15 +0,0 @@ -Expecting value: line 1 column 1 (char 0). file: api_caller.py. line: 658. type: - Traceback (most recent call last): - File "api_caller.py", line 658, in - if checkStocks(stock_time, stock_frequency) or msg == 's': - File "api_caller.py", line 571, in checkStocks - all_stocks_settings = json.load(f) - File "/usr/lib/python3.7/json/__init__.py", line 296, in load - parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw) - File "/usr/lib/python3.7/json/__init__.py", line 348, in loads - return _default_decoder.decode(s) - File "/usr/lib/python3.7/json/decoder.py", line 337, in decode - obj, end = self.raw_decode(s, idx=_w(s, 0).end()) - File "/usr/lib/python3.7/json/decoder.py", line 355, in raw_decode - raise JSONDecodeError("Expecting value", s, err.value) from None -json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0) diff --git a/server.py b/server.py index 8ce04b4..c08fa58 100644 --- a/server.py +++ b/server.py @@ -306,6 +306,21 @@ def wifi(): # resstart netoworking os.system('wpa_cli -i wlan0 reconfigure') return index() + +def edit_hosts(hostname): + current_hosts = open('/etc/hosts') + + hosts_lines = current_hosts.readlines() + print(hosts_lines[5]) + + hosts_lines[5] = '127.0.1.1 {}'.format(hostname) + + current_hosts.close() + + hosts_string = ''.join(hosts_lines) + + current_hosts = open('/etc/hosts', 'w+') + current_hosts.write(hosts_string) @app.route("/hostname", methods = ['PUT', 'POST', 'GET']) def hostname(): @@ -313,6 +328,8 @@ def hostname(): settings = json.loads(data) hostname = settings['hostname'] print('hostname', hostname) + + edit_hosts(hostname) os.system("sudo hostnamectl set-hostname {}".format(hostname)) os.system("sudo systemctl restart avahi-daemon")