views.py 594 B

1234567891011121314151617181920212223
  1. from django.shortcuts import render
  2. from rest_framework import generics, status
  3. from rest_framework.response import Response
  4. from rest_framework.views import APIView
  5. from myapp.models import MyRequest
  6. from myapp.serializers import RequestSerializer
  7. # Create your views here.
  8. class GetInfo(APIView):
  9. def get(self, request):
  10. data = {
  11. "message": "Hello World get"
  12. }
  13. return Response(data)
  14. def post(self, request):
  15. data = {
  16. "message": "Hello World post",
  17. "received": request.data
  18. }
  19. return Response(data)