Skip to content

Commit 6db953e

Browse files
author
Syntax-Vibe-Amir
committed
Fix 404 by serving index.html from /
1 parent 4b9e4d1 commit 6db953e

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

backend/app.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
11
from flask import Flask, jsonify, send_from_directory
22
import psutil
3-
from datetime import datetime
3+
import datetime
44
import os
55

6-
app = Flask(__name__, static_folder='frontend')
6+
app = Flask(__name__, static_folder="frontend")
77

8-
@app.route('/health')
8+
@app.route("/")
9+
def index():
10+
return send_from_directory(app.static_folder, "index.html")
11+
12+
@app.route("/health")
913
def health():
1014
return jsonify({
11-
"cpu": f"{psutil.cpu_percent()}%",
12-
"disk": f"{psutil.disk_usage('/').percent}%",
13-
"memory": f"{psutil.virtual_memory().percent}%",
14-
"time": datetime.now().strftime("%H:%M:%S")
15+
"cpu": psutil.cpu_percent(),
16+
"ram": psutil.virtual_memory().percent,
17+
"disk": psutil.disk_usage('/').percent,
18+
"time": datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
1519
})
1620

17-
@app.route('/')
18-
def index():
19-
return send_from_directory(app.static_folder, 'index.html')
21+
if __name__ == "__main__":
22+
app.run(debug=False, host="0.0.0.0")

0 commit comments

Comments
 (0)