Initial commit: Flask API with Docker support
هذا الالتزام موجود في:
40
app.py
Normal file
40
app.py
Normal file
@@ -0,0 +1,40 @@
|
||||
from flask import Flask, jsonify
|
||||
from datetime import datetime
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
request_count = 0
|
||||
|
||||
|
||||
@app.before_request
|
||||
def count_requests():
|
||||
global request_count
|
||||
request_count += 1
|
||||
|
||||
|
||||
@app.route("/")
|
||||
def home():
|
||||
return jsonify({
|
||||
"message": "Welcome to Ghaymah SRE API",
|
||||
"timestamp": datetime.utcnow().isoformat() + "Z"
|
||||
})
|
||||
|
||||
|
||||
@app.route("/health")
|
||||
def health():
|
||||
return jsonify({
|
||||
"status": "healthy",
|
||||
"service": "ghaymah-sre-api",
|
||||
"timestamp": datetime.utcnow().isoformat() + "Z"
|
||||
})
|
||||
|
||||
|
||||
@app.route("/stats")
|
||||
def stats():
|
||||
return jsonify({
|
||||
"requests": request_count
|
||||
})
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
app.run(host="0.0.0.0", port=5000)
|
||||
المرجع في مشكلة جديدة
حظر مستخدم