Print raw api response
This commit is contained in:
parent
eb7667f4f5
commit
4e1c38c0ed
7
backend/api/urls.py
Normal file
7
backend/api/urls.py
Normal file
@ -0,0 +1,7 @@
|
||||
from django.urls import path
|
||||
|
||||
from . import views
|
||||
|
||||
urlpatterns = [
|
||||
path('',views.api_home)
|
||||
]
|
@ -1,3 +1,4 @@
|
||||
from django.shortcuts import render
|
||||
from django.http import JsonResponse
|
||||
|
||||
# Create your views here.
|
||||
def api_home(request,*args,**kwargs):
|
||||
return JsonResponse({"message":"This is my 1st Django api project"})
|
@ -15,8 +15,9 @@ Including another URLconf
|
||||
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
||||
"""
|
||||
from django.contrib import admin
|
||||
from django.urls import path
|
||||
from django.urls import path,include
|
||||
|
||||
urlpatterns = [
|
||||
path('admin/', admin.site.urls),
|
||||
path('api/',include('api.urls'))
|
||||
]
|
||||
|
@ -1,8 +1,7 @@
|
||||
import requests
|
||||
|
||||
endpoint = "http://127.0.0.1:8000/"
|
||||
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())
|
||||
print(get_response.json()['message'])
|
||||
print(get_response.status_code)
|
Loading…
x
Reference in New Issue
Block a user