63 lines
1.9 KiB
Python
63 lines
1.9 KiB
Python
import webbrowser
|
|
import threading
|
|
import asyncio
|
|
import markdown
|
|
import tornado.web
|
|
import navpoint.fix_path
|
|
|
|
class AboutHandler(tornado.web.RequestHandler):
|
|
def get(self):
|
|
with open(navpoint.fix_path.fix_path("README.md")) as f:
|
|
readme = markdown.markdown(
|
|
f.read()
|
|
.replace("https://www.gnu.org/licenses/gpl-3.0.en.html", "#gpl")
|
|
.replace(
|
|
"https://creativecommons.org/licenses/by-sa/4.0/", "#cc"
|
|
)
|
|
)
|
|
|
|
with open(navpoint.fix_path.fix_path("GPL-3.0.txt")) as f:
|
|
gpl = f.read()
|
|
|
|
with open(navpoint.fix_path.fix_path("CC-BY-SA-4.0.txt")) as f:
|
|
cc = f.read()
|
|
|
|
self.write(
|
|
f"""\
|
|
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>Navpoint Desktop</title>
|
|
</head>
|
|
<body>
|
|
<a id="top"></a>{readme}
|
|
<h3 id="gpl">GNU General Public License v3.0</h3>
|
|
<p>If you are connected to the Internet, this license is also available <a href="https://www.gnu.org/licenses/gpl-3.0.en.html">on the GNU Web site</a>.</p>
|
|
<pre>{gpl}</pre>
|
|
<p id="cc"><a href="#top">Back to top</a></p>
|
|
<h3>Creative Commons Attribution-ShareAlike 4.0 International</h3>
|
|
<p>If you are connected to the Internet, this license, along with a more easily-readable summary, is available <a href="https://creativecommons.org/licenses/by-sa/4.0/">on the Creative Commons Web site</a>.</p>
|
|
<pre>{cc}</pre>
|
|
<p><a href="#top">Back to top</a></p>
|
|
</body>
|
|
</html>
|
|
"""
|
|
)
|
|
|
|
|
|
async def _run():
|
|
app = tornado.web.Application(
|
|
[
|
|
("/", AboutHandler),
|
|
]
|
|
)
|
|
app.listen(9999, address="127.0.0.1")
|
|
await asyncio.Event().wait()
|
|
|
|
def run_server():
|
|
threading.Thread(target=asyncio.run, args=(_run(),), daemon=True).start()
|
|
|
|
|
|
def about():
|
|
webbrowser.open("http://127.0.0.1:9999/")
|