diff --git a/q1-deploy-monitor/Dockerfile b/q1-deploy-monitor/Dockerfile index e69de29..45818e6 100644 --- a/q1-deploy-monitor/Dockerfile +++ b/q1-deploy-monitor/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 8000 + +CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000"] diff --git a/q1-deploy-monitor/__pycache__/app.cpython-313.pyc b/q1-deploy-monitor/__pycache__/app.cpython-313.pyc new file mode 100644 index 0000000..830c605 Binary files /dev/null and b/q1-deploy-monitor/__pycache__/app.cpython-313.pyc differ diff --git a/q1-deploy-monitor/app.py b/q1-deploy-monitor/app.py new file mode 100644 index 0000000..914857d --- /dev/null +++ b/q1-deploy-monitor/app.py @@ -0,0 +1,40 @@ +from fastapi import FastAPI +import time + +app = FastAPI() + +request_count = 0 + + +@app.get("/") +def home(): + global request_count + request_count += 1 + + return { + "message": "Application is running" + } + + +@app.get("/health") +def health(): + return { + "status": "UP" + } + + +@app.get("/stats") +def stats(): + global request_count + + start = time.time() + + request_count += 1 + + response_time = round((time.time() - start) * 1000, 2) + + return { + "status": "UP", + "requests": request_count, + "response_time": response_time + } diff --git a/q1-deploy-monitor/dashboard.html b/q1-deploy-monitor/dashboard.html index e69de29..aed253c 100644 --- a/q1-deploy-monitor/dashboard.html +++ b/q1-deploy-monitor/dashboard.html @@ -0,0 +1,98 @@ + + +
+ + ++ Status: + Loading... +
+ ++ Requests: + 0 +
+ ++ Response Time: + 0 ms +
+ +