commit 5e49b44bca7557fea427bb3ac58534ca6a83af0b Author: hassan90122 Date: Tue Jul 28 17:22:01 2026 +0000 Initial commit: Flask API with Docker support diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..93b4bba --- /dev/null +++ b/.gitignore @@ -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/ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..c738cb3 --- /dev/null +++ b/Dockerfile @@ -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"] diff --git a/app.py b/app.py new file mode 100644 index 0000000..d1be3bd --- /dev/null +++ b/app.py @@ -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) diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..af266d2 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +Flask==3.1.3