Django curl request

2.2k Views Asked by At

Im trying to use curl to hit an endpoint in my Django application and havent been successful returning my data.

curl 127.0.0.1:8000/myapp/[email protected]&part=123434

my server shows a 301 when the curl goes through, however; none of the print statements are ran in my view, and i am not able to get the querystring parameters using request.GET.get().

[21/Aug/2018 00:26:59] "GET /myapp/[email protected] HTTP/1.1" 301 0

view.py

def index(request):
    if request.method == 'GET':
        print('hello world')
        email = request.GET.get('email')
        part = request.POST.get('part')
        print(email)
        print(part)
        df = generate_dataframe('apps/myapp/data.csv')
        df = get_dataframe_by_part(part, df)
        bool = check_all(email, df)
        response_data = {}
        response_data['DoesUserExist'] = bool
        return HttpResponse(json.dumps(response_data), content_type="application/json")

urls.py

urlpatterns = patterns('',
                      url(r'myapp/', include('myapp.urls')),
                      )

myapp/urls.py

urlpatterns = patterns('',
                       url(r'^$', 'myapp.views.index', name='index'),
                       )
1

There are 1 best solutions below

0
Siddaram H On

The description for 301 error is

The HTTP response status code 301 Moved Permanently is used for permanent URL redirection, meaning current links or records using the URL that the response is received for should be updated.

from 301 error

Hence the issue could be different. check first, whether you can able to load from chrome and the urls are correct