initial commit
This commit is contained in:
1
core/api/__init__.py
Normal file
1
core/api/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
13
core/api/schemas.py
Normal file
13
core/api/schemas.py
Normal file
@@ -0,0 +1,13 @@
|
||||
from typing import Optional
|
||||
|
||||
from ninja import Schema
|
||||
|
||||
|
||||
class MessageSchema(Schema):
|
||||
message: str
|
||||
|
||||
|
||||
class ErrorSchema(Schema):
|
||||
error: str
|
||||
details: Optional[str] = None
|
||||
|
||||
15
core/api/views.py
Normal file
15
core/api/views.py
Normal file
@@ -0,0 +1,15 @@
|
||||
from ninja import Router
|
||||
|
||||
from django.db import connection
|
||||
from django.utils import timezone
|
||||
|
||||
health_router = Router()
|
||||
|
||||
@health_router.get("/health")
|
||||
def health(request):
|
||||
try:
|
||||
with connection.cursor() as c:
|
||||
c.execute("SELECT 1;")
|
||||
return {"status": "ok", "time": timezone.now().isoformat()}
|
||||
except Exception as e:
|
||||
return {"status": "error", "error": str(e)}, 500
|
||||
Reference in New Issue
Block a user