Thursday, May 7, 2015

Re: Sending Data from client side(another computer) to Django(my computer) using Socket library

On Thu, May 7, 2015 at 3:00 PM, steve malise <stviaswggr@gmail.com> wrote:
> What i am trying to do is run python script(client side) on another computer
> which is on same network with my computer,then receive data from another
> computer with the django(which is running on my computer(server side)).i am
> using built-in "runserver".
>
> The error comes when i runserver and send data from another computer to
> django,then i get this "code 400, message Bad request syntax ( data from
> another computer)"
>

Write a simple django view like this:

def myview(request):
return HttpResponse(request.raw_post_data)

In your client python script, use one of the libraries I mentioned, eg requests:

import requests
req = requests.post('http://hostname/url', data='hello world')
print req.text

Go from there..

Cheers

Tom

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAFHbX1K0Heb94TcrWRo-yEsf%2BM04bMWRKH-rLRasreWrJEr21A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment