41 lines
No EOL
951 B
Python
41 lines
No EOL
951 B
Python
from django.shortcuts import render
|
|
from django.http import JsonResponse
|
|
from django.views.decorators.csrf import csrf_exempt
|
|
|
|
import json
|
|
import requests
|
|
# Create your views here.
|
|
|
|
def send_wells(request):
|
|
print("sending wells")
|
|
payload = {'data':[
|
|
{
|
|
"id": 1,
|
|
"license": "12-d-13",
|
|
},
|
|
{
|
|
"id": 2,
|
|
"license": "16-a-111",
|
|
},]
|
|
}
|
|
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
|
|
) |