Spaces:
Paused
Paused
Kastg
commited on
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,7 +5,7 @@ from PIL import Image
|
|
| 5 |
from io import BytesIO
|
| 6 |
import psutil
|
| 7 |
import time
|
| 8 |
-
import datetime
|
| 9 |
|
| 10 |
app = Flask(__name__)
|
| 11 |
|
|
@@ -19,14 +19,11 @@ def uptime():
|
|
| 19 |
|
| 20 |
@app.route("/ping")
|
| 21 |
def ping():
|
| 22 |
-
# Ping an external service
|
| 23 |
try:
|
| 24 |
-
|
| 25 |
-
response = requests.get("https://kastg-cdn.hf.space/") # Change this to your desired external service
|
| 26 |
response.raise_for_status()
|
| 27 |
-
|
| 28 |
-
elapsed_time_ms = round((end_time - start_time) * 1000, 2) # Calculate elapsed time in milliseconds
|
| 29 |
-
return jsonify({"ping": "success", "response_time_ms": elapsed_time_ms})
|
| 30 |
except requests.exceptions.RequestException as e:
|
| 31 |
return jsonify({"ping": f"failed: {str(e)}"}), 500
|
| 32 |
|
|
|
|
| 5 |
from io import BytesIO
|
| 6 |
import psutil
|
| 7 |
import time
|
| 8 |
+
import datetime # Add this line to import datetime module
|
| 9 |
|
| 10 |
app = Flask(__name__)
|
| 11 |
|
|
|
|
| 19 |
|
| 20 |
@app.route("/ping")
|
| 21 |
def ping():
|
| 22 |
+
# Ping an external service
|
| 23 |
try:
|
| 24 |
+
response = requests.get("https://example.com") # Change this to your desired external service
|
|
|
|
| 25 |
response.raise_for_status()
|
| 26 |
+
return jsonify({"ping": "success"})
|
|
|
|
|
|
|
| 27 |
except requests.exceptions.RequestException as e:
|
| 28 |
return jsonify({"ping": f"failed: {str(e)}"}), 500
|
| 29 |
|