Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
CHATBOT-PROJECT1/apiviews.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
22 lines (19 sloc)
684 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.shortcuts import render | |
from django.http import Http404 | |
from rest_framework.views import ApiView | |
from rest_framework.decorators import api_view | |
from rest_framework.response import Response | |
from rest_framework import status | |
from django.http import JsonResponse | |
from django.core import serializers | |
from django.conf import settings | |
import json | |
# Create your views here. | |
@api_view(["POST"]) | |
def ProperWeight(heightvalue): | |
try: | |
height=json.loads(heightvalue.body) | |
weight=str(height*15) | |
return JsonResponse("Ideal weight should be:"weight+"kg" safe=False) | |
except ValueError as e: | |
return Response(e.args[0],status.HTTP_400_BAD_REQUEST) |