Skip to content

Commit 04d3e7c

Browse files
authored
Merge pull request #23 from codeguru42/22-health-check
Add health_check route
2 parents e80a2b2 + a263feb commit 04d3e7c

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

go_capture/urls.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,5 @@
2121
urlpatterns = [
2222
path('admin/', admin.site.urls),
2323
path('capture/', views.capture),
24+
path('health_check/', views.health_check),
2425
]

go_capture/views.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
import cv2
44
import numpy as np
5-
from django.http import FileResponse
6-
from django.views.decorators.http import require_POST
5+
from django.http import FileResponse, JsonResponse
6+
from django.views.decorators.http import require_POST, require_GET
77

88
from go_capture.sgf import perspective, find_stones
99
from go_capture.sgf.make_sgf import make_sgf
@@ -20,3 +20,11 @@ def capture(request):
2020
make_sgf(file, black, white)
2121
file.seek(0)
2222
return FileResponse(file.read(), status=201, as_attachment=True, content_type='application/x-go-sgf')
23+
24+
25+
@require_GET
26+
def health_check(request):
27+
body = {
28+
'message': 'Healthy!'
29+
}
30+
return JsonResponse(body)

requests.http

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
### health check
2+
GET http://{{host}}:{{port}}/health_check/
3+
4+
### POST image
5+
16
POST http://{{host}}:{{port}}/capture/
27
Content-Type: multipart/form-data; boundary=WebAppBoundary
38

0 commit comments

Comments
 (0)