changed the query format so that the parameters are extracted from the query string instead

This commit is contained in:
Никита Тырин 2024-09-18 16:28:50 +03:00
parent ee8624e2ab
commit fae86166e4
2 changed files with 11 additions and 5 deletions

View File

@ -3,7 +3,7 @@ from .views import ConeSearchView
urlpatterns = [ urlpatterns = [
path( path(
'cone_search/<str:ra>/<str:dec>/<str:radius>', 'cone_search/',
ConeSearchView.as_view(), ConeSearchView.as_view(),
name = 'cone_search' name = 'cone_search'
), ),

View File

@ -49,11 +49,17 @@ class ConeSearchView(APIView):
def get(self, request, ra, dec, radius): def get(self, request): # ra, dec, radius):
radius = float(radius) try:
ra = float(ra) ra = float(request.query_params.get('ra'))
dec = float(dec) dec = float(request.query_params.get('dec'))
radius = float(request.query_params.get('radius'))
except (TypeError, ValueError):
return Response({"error": "Invalid parameters"}, status=status.HTTP_400_BAD_REQUEST)
# radius = float(radius)
# ra = float(ra)
# dec = float(dec)
nside = 2048 nside = 2048
#create skycoord for the center of search #create skycoord for the center of search