Standalone app for deployment
هذا الالتزام موجود في:
12
Dockerfile
Normal file
12
Dockerfile
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
FROM python:3.11-slim
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY requirements.txt .
|
||||||
|
RUN pip install --no-cache-dir -r requirements.txt
|
||||||
|
|
||||||
|
COPY app.py .
|
||||||
|
|
||||||
|
EXPOSE 5000
|
||||||
|
|
||||||
|
CMD ["python", "app.py"]
|
||||||
22
app.py
Normal file
22
app.py
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
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": "API is running", "requests": request_count})
|
||||||
|
|
||||||
|
@app.route('/health')
|
||||||
|
def health():
|
||||||
|
return jsonify({
|
||||||
|
"status": "healthy",
|
||||||
|
"uptime_seconds": round(time.time() - start_time, 2)
|
||||||
|
}), 200
|
||||||
|
|
||||||
|
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.0.0
|
||||||
المرجع في مشكلة جديدة
حظر مستخدم