rastof9 commited on
Commit
b1d48b4
·
verified ·
1 Parent(s): 3d67717

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -0
app.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from flask import Flask, Response
2
+
3
+ app = Flask(__name__)
4
+
5
+ # Path to Minecraft server log
6
+ LOG_FILE = "/data/logs/latest.log"
7
+
8
+ @app.route("/")
9
+ def stream_logs():
10
+ def generate():
11
+ try:
12
+ with open(LOG_FILE, "r") as f:
13
+ # Go to the end of file
14
+ f.seek(0, 2)
15
+ while True:
16
+ line = f.readline()
17
+ if line:
18
+ yield line + "<br>"
19
+ except Exception as e:
20
+ yield f"Error reading log: {e}"
21
+ return Response(generate(), mimetype="text/html")
22
+
23
+ if __name__ == "__main__":
24
+ app.run(host="0.0.0.0", port=7860)