Django - Ping Pong API

김세준·2021년 5월 5일

# app/urls.py

from django.urls import path
from src.views import PingAPI

urlpatterns = [
    path('', PingAPI.as_view()),
]

# src/views.py

from rest_framework.views import Response, APIView
import os


class PingAPI(APIView):
    def get(self, *args, **kwargs):
        return Response({
            'ping': 'pong'
        })

flask-restful 처럼 class-based view를 사용했다. 참고 link

0개의 댓글