diff --git a/backend/api/views.py b/backend/api/views.py index 00913fc..a4a7c96 100644 --- a/backend/api/views.py +++ b/backend/api/views.py @@ -1,4 +1,14 @@ +import json from django.http import JsonResponse def api_home(request,*args,**kwargs): - return JsonResponse({"message":"This is my 1st Django api project"}) \ No newline at end of file + 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) \ No newline at end of file diff --git a/py_client/basic.py b/py_client/basic.py index f27ce19..90624f9 100644 --- a/py_client/basic.py +++ b/py_client/basic.py @@ -1,7 +1,7 @@ import requests endpoint = "http://127.0.0.1:8000/api/" -get_response = requests.get(endpoint,json={"query": "Hello world"}) #HTTP Request -print(get_response.text) # print raw text response -print(get_response.json()['message']) +get_response = requests.get(endpoint,params={"abc":123}, json={"query": "Hello world"}) #HTTP Request +#print(get_response.text) # print raw text response +print(get_response.json()) print(get_response.status_code) \ No newline at end of file