|
@ -1,4 +1,14 @@ |
|
|
|
|
|
import json |
|
|
from django.http import JsonResponse |
|
|
from django.http import JsonResponse |
|
|
|
|
|
|
|
|
def api_home(request,*args,**kwargs): |
|
|
def api_home(request,*args,**kwargs): |
|
|
return JsonResponse({"message":"This is my 1st Django api project"}) |
|
|
|
|
|
|
|
|
body = request.body # byte string of Json data |
|
|
|
|
|
data = {} |
|
|
|
|
|
try: |
|
|
|
|
|
data = json.loads(body) #string of json data ---> python dict |
|
|
|
|
|
except: |
|
|
|
|
|
pass |
|
|
|
|
|
data['headers'] = dict(request.headers) |
|
|
|
|
|
data['content_type'] = request.content_type |
|
|
|
|
|
print(data) |
|
|
|
|
|
return JsonResponse(data) |