Kastg commited on
Commit
6a97cfb
·
verified ·
1 Parent(s): 017022b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -1
app.py CHANGED
@@ -3,6 +3,8 @@ import os
3
  import requests
4
  from PIL import Image
5
  from io import BytesIO
 
 
6
 
7
  app = Flask(__name__)
8
 
@@ -64,5 +66,24 @@ def upload_image():
64
  return jsonify({"message": "File uploaded successfully", "image_url": full_image_url})
65
 
66
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
67
  if __name__ == "__main__":
68
- app.run(host="0.0.0.0", port=7860, debug=True)
 
3
  import requests
4
  from PIL import Image
5
  from io import BytesIO
6
+ import psutil
7
+ import time
8
 
9
  app = Flask(__name__)
10
 
 
66
  return jsonify({"message": "File uploaded successfully", "image_url": full_image_url})
67
 
68
 
69
+ @app.route("/uptime")
70
+ def uptime():
71
+ # Get system uptime using psutil
72
+ uptime_seconds = int(time.time() - psutil.boot_time())
73
+ uptime_string = str(datetime.timedelta(seconds=uptime_seconds))
74
+ return jsonify({"uptime": uptime_string})
75
+
76
+
77
+ @app.route("/ping")
78
+ def ping():
79
+ # Ping an external service
80
+ try:
81
+ response = requests.get("https://example.com") # Change this to your desired external service
82
+ response.raise_for_status()
83
+ return jsonify({"ping": "success"})
84
+ except requests.exceptions.RequestException as e:
85
+ return jsonify({"ping": f"failed: {str(e)}"}), 500
86
+
87
+
88
  if __name__ == "__main__":
89
+ app.run(host="0.0.0.0", port=7860, debug=True)