From 1e11f8244ff9f843a7e61083783fb8d59800b570 Mon Sep 17 00:00:00 2001 From: Mikhail Lobanov Date: Wed, 14 Oct 2026 01:22:01 +0300 Subject: [PATCH] feat: add initial health-check application --- .gitignore | 5 +++++ README.md | 33 +++++++++++++++++++++++++++++++++ app/app.py | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 73 insertions(+) create mode 100644 .gitignore create mode 100644 README.md create mode 100644 app/app.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..636172b --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +__pycache__/ +*.py[cod] +.venv/ +.env +*.log diff --git a/README.md b/README.md new file mode 100644 index 0000000..bf72b9a --- /dev/null +++ b/README.md @@ -0,0 +1,33 @@ +# DevOps Platform + +Учебный проект для практики DevOps в течение 3 месяцев. + +## Application + +Минимальный HTTP-сервис на Python без внешних зависимостей. + +## Endpoints + +- GET / — информация о приложении +- GET /health — проверка работоспособности +- Другие пути — HTTP 404 + +## Local run + + python3 app/app.py + +Приложение слушает 127.0.0.1:8000. + +## Health check + + curl -i http://127.0.0.1:8000/health + +## Roadmap + +1. Git workflow +2. Docker and Compose +3. GitLab CI/CD +4. Ansible +5. Terraform +6. Prometheus and Grafana +7. Kubernetes diff --git a/app/app.py b/app/app.py new file mode 100644 index 0000000..e4629a9 --- /dev/null +++ b/app/app.py @@ -0,0 +1,35 @@ +import json +from http.server import BaseHTTPRequestHandler, HTTPServer + + +class Handler(BaseHTTPRequestHandler): + def do_GET(self): + if self.path == "/health": + status = 200 + body = {"status": "ok"} + elif self.path == "/": + status = 200 + body = { + "application": "devops-platform", + "version": "1.0.0" + } + else: + status = 404 + body = {"error": "not found"} + + payload = json.dumps(body).encode("utf-8") + + self.send_response(status) + self.send_header("Content-Type", "application/json") + self.send_header("Content-Length", str(len(payload))) + self.end_headers() + self.wfile.write(payload) + + def log_message(self, format, *args): + print(f"{self.client_address[0]} - {format % args}") + + +if __name__ == "__main__": + server = HTTPServer(("127.0.0.1", 8000), Handler) + print("Listening on http://127.0.0.1:8000") + server.serve_forever()