lainlives hace 3 días
padre
commit
79297f8aad

+ 10 - 1
README.md

@@ -48,4 +48,13 @@ python main.py --admin Owner:supersecret
 ### Accessing the Room
 1. Open your browser and navigate to `http://localhost:2004` (or whatever port you configured).
 2. Enter your desired handle.
-3. Draw, type, and chat! All history is permanently stored in a local SQLite database (`chat.db`) and safely pruned down to the 500 most recent messages automatically.
+3. Draw, type, and chat! All history is permanently stored in a local SQLite database (`chat.db`) and safely pruned down to the 500 most recent messages automatically.
+
+
+## Screenshots
+
+-  <img src="screenshots/colors.png" />
+-  <img src="screenshots/beeg.png" />
+-  <img src="screenshots/mobile.png" />
+-  <img src="screenshots/overlay.png" />
+-  <img src="screenshots/expand.png" />

+ 27 - 8
main.py

@@ -69,6 +69,9 @@ clients = []
 @app.route("/")
 @app.route("/<path:filename>")
 def static_files(filename="index.html"):
+    if request.args.get("stream") == "1" and filename == "index.html":
+        return send_from_directory("public", filename)
+
     if "u" in request.args and filename == "index.html":
         username = request.args.get("u")
         session_id = request.cookies.get("session_id")
@@ -231,15 +234,18 @@ def post_message():
 # GET: all clients listen here, with long-polling
 @app.route("/api/messages", methods=["GET"])
 def get_messages():
-    session_id = request.cookies.get("session_id")
-    with db_lock:
-        conn = sqlite3.connect("chat.db", check_same_thread=False)
-        c = conn.cursor()
-        c.execute("SELECT 1 FROM users WHERE session_id = ?", (session_id,))
-        if not c.fetchone():
+    is_stream = request.args.get("stream") == "1"
+    
+    if not is_stream:
+        session_id = request.cookies.get("session_id")
+        with db_lock:
+            conn = sqlite3.connect('chat.db', check_same_thread=False)
+            c = conn.cursor()
+            c.execute("SELECT 1 FROM users WHERE session_id = ?", (session_id,))
+            if not c.fetchone():
+                conn.close()
+                return {"error": "Unauthorized"}, 401
             conn.close()
-            return {"error": "Unauthorized"}, 401
-        conn.close()
 
     q = queue.Queue()
     clients.append(q)
@@ -294,6 +300,19 @@ def download_images():
 
 @app.route("/api/backlog", methods=["GET"])
 def get_backlog():
+    is_stream = request.args.get("stream") == "1"
+    
+    if not is_stream:
+        session_id = request.cookies.get("session_id")
+        with db_lock:
+            conn = sqlite3.connect('chat.db', check_same_thread=False)
+            c = conn.cursor()
+            c.execute("SELECT 1 FROM users WHERE session_id = ?", (session_id,))
+            if not c.fetchone():
+                conn.close()
+                return {"error": "Unauthorized"}, 401
+            conn.close()
+
     log(f"Backlog requested by {request.remote_addr}")
     with db_lock:
         conn = sqlite3.connect("chat.db", check_same_thread=False)

+ 9 - 3
public/js/service.js

@@ -210,8 +210,9 @@ function handleMessage(msg) {
 // listens for new messages from the server
 async function listen() {
   try {
-    const response = await fetch("/api/messages");
-    if (response.status === 401) {
+    const url = isStreamMode ? "/api/messages?stream=1" : "/api/messages";
+    const response = await fetch(url);
+    if (response.status === 401 && !isStreamMode) {
       window.location.href = "/";
       return;
     }
@@ -230,7 +231,12 @@ async function listen() {
 // load backlog first, then start listening
 async function loadBacklog() {
   try {
-    const response = await fetch("/api/backlog");
+    const url = isStreamMode ? "/api/backlog?stream=1" : "/api/backlog";
+    const response = await fetch(url);
+    if (response.status === 401 && !isStreamMode) {
+      window.location.href = "/";
+      return;
+    }
     if (response.status === 200) {
       const messages = await response.json();
       // append chronologically

BIN
screenshots/beeg.png


BIN
screenshots/colors.png


BIN
screenshots/dark.png


BIN
screenshots/expand.png


BIN
screenshots/floatingobs.png


BIN
screenshots/large.png


BIN
screenshots/light.png


BIN
screenshots/mobile.png


BIN
screenshots/obssource.png


BIN
screenshots/overlay.png