38 أسطر
663 B
Python
38 أسطر
663 B
Python
from flask import Flask, jsonify
|
|
import time
|
|
|
|
app = Flask(__name__)
|
|
|
|
request_count = 0
|
|
start_time = time.time()
|
|
|
|
|
|
@app.route("/")
|
|
def home():
|
|
global request_count
|
|
request_count += 1
|
|
return jsonify({
|
|
"message": "Hello from Ghaymah!",
|
|
"timestamp": time.time()
|
|
})
|
|
|
|
|
|
@app.route("/health")
|
|
def health():
|
|
global request_count
|
|
request_count += 1
|
|
return jsonify({
|
|
"status": "healthy"
|
|
})
|
|
|
|
|
|
@app.route("/metrics")
|
|
def metrics():
|
|
return jsonify({
|
|
"request_count": request_count,
|
|
"uptime": round(time.time() - start_time, 2)
|
|
})
|
|
|
|
|
|
if __name__ == "__main__":
|
|
app.run(host="0.0.0.0", port=5000) |