From f1bd12885ca515f0687afdd45b177f7dec8be3df Mon Sep 17 00:00:00 2001 From: Neythen Date: Mon, 29 Nov 2021 15:17:55 +0000 Subject: [PATCH] hosts changed --- display_images/Crypto.ppm | Bin 67022 -> 67022 bytes log.txt | 15 --------------- server.py | 17 +++++++++++++++++ 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/display_images/Crypto.ppm b/display_images/Crypto.ppm index fc72427168a095a82df46b00ee46815775930bce..ecc1327e85dd648e39e7787db9a82c32ea8672e0 100755 GIT binary patch delta 1274 zcmZ8hTWAwm7-rHMnKC-lWK*LPhbdMciqX*4it8o82Q6wfMSW0K4C{jUun_P;5X8Xh zgNihhPp#r@YFq2w=#i*MZK|wV)R=v6SB0g;2cZ?T_F)$nq5kL0n09@b3o~cF+yBie z94apyD$kxgjlms$9K2qM{5dbwv);C1x#WXwWRDi5Ds-HA)n=AS(PJLTpko)b?OwLg z-s<5`m5J;BfOf@z-4H-xR?W@MehGFVfb5?-eb#E3^#tcf;ruHkhobyrgP(R2p27}X z_{rn0j#_3r23wjCSy_$z&%riLl0t}Vo`Yn_i(*L5tWwyWD^UrtZXb%50?2n(AXS)e znHj_d8ng8cd*>C`iwTS%&cSja$r@f0?4Yk?$?@~3Ax zdKU?_@a;#W*FfS%7^zR~q*i4g?!+gky+qJD;w|+Yl4}{d;hs4ZL&Id) zkEUY&J#}2{ae@!wm)^^;yCcL{3yl%YXCG1RVp`vLAk2QaUqX77m#zN2k!zegg$J{Iq9_IzU|v^DVi_UmYE~8D)hVn zp~+MS9jSkVNcGWF4Sj+>J~S1{6=5Xr`;qQnoyqg%LzWprGOptK0U23Kp{o}IQ+<|M zL$a2*@>*}0%N#r1FUgL^R7b#Pg}Or1Zxy+}{|oe3A*U^tNfRq&vxnKQH&OhQDNWXK zvv+3zv32G6wK9Q^&j~}tyn>A3o<`!V|E{R!MHQ*HPeuH*2lu&=8${7Gkp}kbBjR0g zbPO>vHSZ~rh^zjsS8g;4v5>1~32I#h^S`4e#Xkl3L(5!CJhia>Iudh(mRSWYyTmP& z6SIwg=tnHahacoIw<0pSkQzE(9_KzlA5+5Z!&Hx;d(5=V=_K6{7~&T>H;r4N zk#cEKk|QHLc1jf2{8)z=dxnt>HAs{-mbMSEhlo><{u}TAw=iB}zCpxt)j5we;Bi&| F{S_f&81Mi9 delta 1195 zcmZvcTWAwm9LAZn2BwZqoH81nI*e>pEJlKt2wK)6sLN_G;wpGq45;|DSoA><#DKn3 z5i|K*L^PUOU03Vcv`6h?ZIc$P6}K^hVts0!7Ob}@%RY!uznP4shz}=ca`K<=`~5E` z`ID9Tla-nCsk2svq#$=Wh**ao+0KYn}a}xXQrT3HS&K9qhT;)Tbko$Iv5%S58lM6pdral0nEZ`M1qCZc^hGAWrzcU|evxBhXzUmDO* zxKWGJRUHXFH@%9x4)-!!eSE3jwz3E}YDmmtvYUfMHj-CE-QQ79v!9vf@&iAsIgq$KugKC@>p@EN*o(nEU{8Dtilr8a*8+|Jx@R#4cSl5 zF{i-Yb>uF|NQ`RqWRl~kPU}=Otqoyg-wvd&d1LSdO;Hu?%`!5!!rhONshVxovTgNT zMi*;1Npdip+^#*3@L6N?>ym9*x7M#;0L6BhaDFW4R=hSE-yt|6(l577$m}tW9@LXt zEAiX37~T)9V)w8pFJrWaP3v7#HtDBH4dxb)C)*s`FtVx0gshGr{ql_KS@<}H2Bxy; zvF`1LLt0Kl_gZvag1Wd$RR7DF$#tn-7oXCj4(VzGv4ugDmd`-ExS;IEG*xPZIYoc5 zfHF?Z4xw;h5=x&|62}mU(SFGjZ){>O2`^ z{LY?6_~UYBEA!qPG;n`02yY_LGRpP`y*1mmX7X)bt6}F)gSX8MDRo$TC3?#Uja?X5 ZeMS2rB(Bc)qRqQLX~gGFg8Ofj`2uy}6|DdO 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")