Add "last updated" to mobile mode

This commit is contained in:
Samuel Sloniker 2024-07-23 09:46:08 -07:00
parent 61a9c2ca92
commit d36b75810a

View File

@ -18,6 +18,12 @@ class PostHandler(tornado.web.RequestHandler):
def post(self):
navpoint.content.content = self.request.body
intercom.put(
"Updated",
navpoint.content.content.decode("utf-8")
.split("<description>")[1]
.split("</description>")[0],
)
self.write("Navpoint")
@ -36,16 +42,12 @@ def run_in_thread(ip, token):
def run():
def new_data(purpose, content):
if purpose == "Updated":
updated.config(text="Last updated: " + content)
ip = navpoint.get_ip.get_ip()
token = secrets.token_urlsafe()
threading.Thread(
target=run_in_thread,
args=(
ip,
token,
),
daemon=True,
).start()
link = f"http://{ip}:8888/{token}"
@ -56,6 +58,9 @@ def run():
label = tk.Label(window, text="QR code here...")
label.pack()
updated = ttk.Label(window, text="Waiting for location")
updated.pack()
image = tk.BitmapImage(
data=pyqrcode.create(link).xbm(scale=int(window.winfo_fpixels("2m")))
)
@ -69,4 +74,16 @@ def run():
except tk.TclError:
pass
global intercom
intercom = navpoint.intercom.Intercom(window, new_data)
threading.Thread(
target=run_in_thread,
args=(
ip,
token,
),
daemon=True,
).start()
window.mainloop()