soxogvv commited on
Commit
a4844d1
·
verified ·
1 Parent(s): 46e28f5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -9
app.py CHANGED
@@ -1,4 +1,5 @@
1
- from flask import Flask, Response, request
 
2
  import time
3
 
4
  app = Flask(__name__)
@@ -8,8 +9,6 @@ logs = []
8
  @app.route("/")
9
  def index():
10
  return """
11
- <html>
12
- <body>
13
  <h2>Live Logs</h2>
14
  <pre id="logs"></pre>
15
 
@@ -19,9 +18,6 @@ def index():
19
  document.getElementById("logs").textContent += e.data + "\\n";
20
  };
21
  </script>
22
-
23
- </body>
24
- </html>
25
  """
26
 
27
  @app.route("/stream")
@@ -38,9 +34,15 @@ def stream():
38
 
39
  @app.route("/log", methods=["POST"])
40
  def log():
41
- data = request.json.get("log")
42
- logs.append(data)
43
- return "ok"
 
 
 
 
44
 
 
 
45
 
46
  app.run(host="0.0.0.0", port=7860)
 
1
+ from flask import Flask, request, jsonify
2
+ from flask import Response
3
  import time
4
 
5
  app = Flask(__name__)
 
9
  @app.route("/")
10
  def index():
11
  return """
 
 
12
  <h2>Live Logs</h2>
13
  <pre id="logs"></pre>
14
 
 
18
  document.getElementById("logs").textContent += e.data + "\\n";
19
  };
20
  </script>
 
 
 
21
  """
22
 
23
  @app.route("/stream")
 
34
 
35
  @app.route("/log", methods=["POST"])
36
  def log():
37
+ data = request.json
38
+
39
+ if not data or "log" not in data:
40
+ return jsonify({"error": "no log"}), 400
41
+
42
+ logs.append(data["log"])
43
+ print("LOG RECEIVED:", data["log"]) # 🔥 IMPORTANT DEBUG
44
 
45
+ return jsonify({"status": "ok"})
46
+
47
 
48
  app.run(host="0.0.0.0", port=7860)