diff --git a/proxy/urls.py b/proxy/urls.py index 6071f41..d34863c 100644 --- a/proxy/urls.py +++ b/proxy/urls.py @@ -3,4 +3,6 @@ from .views import * urlpatterns = [ path('get/', send_wells, name='send_wells'), + path('create/', create_well, name='create_well'), + ] \ No newline at end of file diff --git a/proxy/views.py b/proxy/views.py index e720af7..b0065b8 100644 --- a/proxy/views.py +++ b/proxy/views.py @@ -1,5 +1,6 @@ from django.shortcuts import render from django.http import JsonResponse +from django.views.decorators.csrf import csrf_exempt import json import requests @@ -10,11 +11,31 @@ def send_wells(request): payload = {'data':[ { "id": 1, - "licence": "12-d-13", + "license": "12-d-13", }, { "id": 2, - "licence": "16-a-111", + "license": "16-a-111", },] } - return JsonResponse(payload) + return JsonResponse(payload,status = 200) + +@csrf_exempt +def create_well(request): + try: + print("creating wells") + data = request.POST + new_well = data.dict() # change querydict to dict + return JsonResponse({"data":[ + {"error": "OK", + "created": new_well}, + ]}, + status = 200 + ) + except Exception as e: + print(e) + return JsonResponse({"data":[ + {"error": "Bad Request"} + ]}, + status = 400 + ) \ No newline at end of file