Initial demo service for AISP Gitea CI

This commit is contained in:
2026-10-23 08:07:44 +00:00
commit 2c21665d0e
4 changed files with 71 additions and 0 deletions

42
app.py Normal file
View File

@@ -0,0 +1,42 @@
"""Minimal HTTP service for testing AISP's Gitea -> build -> release -> deploy flow."""
import json
import os
import socket
from datetime import datetime, timezone
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
VERSION = "v1"
STARTED_AT = datetime.now(timezone.utc).isoformat()
class Handler(BaseHTTPRequestHandler):
def _send(self, status, body):
data = json.dumps(body).encode()
self.send_response(status)
self.send_header("Content-Type", "application/json")
self.send_header("Content-Length", str(len(data)))
self.end_headers()
self.wfile.write(data)
def do_GET(self):
if self.path == "/healthz":
self._send(200, {"status": "ok"})
elif self.path == "/":
self._send(200, {
"service": "aisp-ci-demo",
"version": VERSION,
"message": os.environ.get("APP_MESSAGE", "Hello from AISP"),
"hostname": socket.gethostname(),
"startedAt": STARTED_AT,
})
else:
self._send(404, {"error": "not found"})
def log_message(self, fmt, *args):
print(f"{self.address_string()} {fmt % args}", flush=True)
if __name__ == "__main__":
port = int(os.environ.get("PORT", "8080"))
print(f"aisp-ci-demo {VERSION} listening on :{port}", flush=True)
ThreadingHTTPServer(("0.0.0.0", port), Handler).serve_forever()