diff --git a/app.py b/app.py index f03448026..f4c13d2b3 100644 --- a/app.py +++ b/app.py @@ -1,7 +1,42 @@ -from flask import Flask, render_template +from flask import Flask +import os +import datetime +import pytz +import subprocess app = Flask(__name__) -@app.route("/") -def hello_world(): - return render_template("index.html", title="Hello") +@app.route('/htop') +def htop(): + # Your full name + full_name = "Mudumal Keshava Reddy" + + # Get system username safely + username = os.getenv("USER") or os.getenv("USERNAME") or "Unknown User" + + # Get server time in IST + ist = pytz.timezone('Asia/Kolkata') + server_time = datetime.datetime.now(ist).strftime("%Y-%m-%d %H:%M:%S %Z") + + # Get top output (first 10 lines) + try: + top_output = subprocess.check_output("top -b -n 1 | head -n 10", shell=True, text=True) + except Exception as e: + top_output = f"Error fetching top output: {e}" + + return f""" + +
Name: {full_name}
+Username: {username}
+Server Time (IST): {server_time}
+{top_output}+ + + """ + +if __name__ == '__main__': + app.run(host='0.0.0.0', port=8080, debug=False)