diff --git a/index.html b/index.html index 33d8f6e..45dc244 100644 --- a/index.html +++ b/index.html @@ -16,11 +16,11 @@ -
+
-
+
-
-
- <{{ peer.destination_hash }}> {{ peer.app_data }} -
-
- - -
-
-
-
-
-
- - -
- - - -
- - -
- - - -
+ +
+ +
+
+
+
+ + + +
+
Peers Discovered ({{ Object.keys(peers).length }})
+
+
+
+
+
-
-
- You - Error - @<{{ chatItem.source_hash }}> -
-
{{ chatItem.message.content }}
-
- -
- +
+
{{ peer.app_data || "Anonymous Peer" }}
+
@<{{ peer.destination_hash.substring(0, 8) }}>
-
- -
-
+ +
+ + +
+ + +
+ + +
+
{{ selectedPeer.app_data || "Anonymous Peer" }}
+
@<{{ selectedPeer.destination_hash }}>
+
+ + +
+
+
+
+ + + +
+
+
+
- -
- -
-
+ + +
+
+
+
+
+
+ + +
+ + + +
+ + +
+ + + +
+ +
+
+
+ You + Error + @<{{ chatItem.source_hash }}> +
+
{{ chatItem.message.content }}
+
+ +
+ +
+
+
+
+
+
+ + +
+
+ + +
+ +
+ +
+
+ +
+
+ +
+ + +
+
+ + + +
+
No Active Chat
+
Select a Peer to start chatting!
+
diff --git a/public/assets/images/user.png b/public/assets/images/user.png new file mode 100644 index 0000000..b24c536 Binary files /dev/null and b/public/assets/images/user.png differ diff --git a/web.py b/web.py index af0c689..8356e2a 100644 --- a/web.py +++ b/web.py @@ -3,6 +3,8 @@ import argparse import http import json +import mimetypes +import os import RNS import LXMF @@ -43,7 +45,7 @@ class ReticulumWebChat: # handle serving custom http paths async def process_request(self, path, request_headers): - + # serve index.html if path == "/": with open("index.html") as f: @@ -51,10 +53,20 @@ class ReticulumWebChat: return http.HTTPStatus.OK, [ ('Content-Type', 'text/html') ], file_content.encode("utf-8") + + # serve anything in public folder + public_file_path = os.path.join("public", path.lstrip("/")) + if os.path.isfile(public_file_path): + mime_type, _ = mimetypes.guess_type(public_file_path) + with open(public_file_path, "rb") as f: + file_content = f.read() + return http.HTTPStatus.OK, [ + ('Content-Type', mime_type) + ], file_content # by default, websocket is always served, but we only want it to be available at /ws # so we will return 404 for everything other than /ws - elif path != "/ws": + if path != "/ws": return http.HTTPStatus.NOT_FOUND, [ ('Content-Type', 'text/html') ], b"Not Found"