Initial commit: Flask API with Docker support
هذا الالتزام موجود في:
20
.gitignore
مباع
Normal file
20
.gitignore
مباع
Normal file
@@ -0,0 +1,20 @@
|
||||
# Python virtual environment
|
||||
venv/
|
||||
|
||||
# Python cache
|
||||
__pycache__/
|
||||
*.pyc
|
||||
*.pyo
|
||||
*.pyd
|
||||
|
||||
# Environment variables
|
||||
.env
|
||||
|
||||
# macOS
|
||||
.DS_Store
|
||||
|
||||
# VS Code
|
||||
.vscode/
|
||||
|
||||
# JetBrains IDEs
|
||||
.idea/
|
||||
13
Dockerfile
Normal file
13
Dockerfile
Normal file
@@ -0,0 +1,13 @@
|
||||
FROM python:3.12-slim
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY requirements.txt .
|
||||
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
COPY . .
|
||||
|
||||
EXPOSE 5000
|
||||
|
||||
CMD ["python", "app.py"]
|
||||
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)
|
||||
1
requirements.txt
Normal file
1
requirements.txt
Normal file
@@ -0,0 +1 @@
|
||||
Flask==3.1.3
|
||||
المرجع في مشكلة جديدة
حظر مستخدم