Always run the about server

This commit is contained in:
Samuel Sloniker 2024-07-29 09:46:36 -07:00
parent 6d4855ff58
commit 1c40a5e418
2 changed files with 3 additions and 14 deletions

View File

@ -1,20 +1,10 @@
import multiprocessing
import webbrowser import webbrowser
import threading import threading
import asyncio import asyncio
import signal
import time
import sys
import os
import markdown import markdown
import tornado.ioloop
import tornado.web import tornado.web
import navpoint.fix_path import navpoint.fix_path
def timed_exit():
time.sleep(3)
os.kill(os.getpid(), signal.SIGTERM)
class AboutHandler(tornado.web.RequestHandler): class AboutHandler(tornado.web.RequestHandler):
def get(self): def get(self):
with open(navpoint.fix_path.fix_path("README.md")) as f: with open(navpoint.fix_path.fix_path("README.md")) as f:
@ -53,7 +43,6 @@ class AboutHandler(tornado.web.RequestHandler):
</html> </html>
""" """
) )
threading.Thread(target=timed_exit).start()
async def _run(): async def _run():
@ -65,10 +54,9 @@ async def _run():
app.listen(9999, address="127.0.0.1") app.listen(9999, address="127.0.0.1")
await asyncio.Event().wait() await asyncio.Event().wait()
def _wrapper(): def run_server():
asyncio.run(_run()) threading.Thread(target=asyncio.run, args=(_run(),), daemon=True).start()
def about(): def about():
multiprocessing.Process(target=_wrapper).start()
webbrowser.open("http://127.0.0.1:9999/") webbrowser.open("http://127.0.0.1:9999/")

View File

@ -46,6 +46,7 @@ def run():
except tk.TclError: except tk.TclError:
pass pass
navpoint.about.run_server()
window.mainloop() window.mainloop()
if mode == "mobile": if mode == "mobile":