I want to display HTTP POST data from client side to on the server side and
what am supposed do to achieve?

On Mon, May 11, 2015 at 3:31 PM, Jani Tiainen <[email protected]> wrote:

> Hi,
>
> Sounds like you're mixing up terms and technologies here and really you
> are trying something that Django was never designed for.
>
> It would be really helpful to know what are you really trying to do,
> instead of just trying techniques that may or may not work for your case.
>
>
> On Mon, 11 May 2015 15:18:37 +0200
> steve malise <[email protected]> wrote:
>
> > Meaning write JavaScript code to make a request?
> > how can achieve it other than writing JavaScript code?
> >
> >
> > On Mon, May 11, 2015 at 3:13 PM, Guilherme Leal <[email protected]>
> wrote:
> >
> > > The "navigation" of your browser always performs a GET method. If
> you're
> > > trying to test that kind of request in the browser, the best aproach
> would
> > > be open the JavaScript and make the request there.
> > >
> > > 2015-05-11 10:09 GMT-03:00 steve malise <[email protected]>:
> > >
> > >> client code:
> > >> import httplib
> > >> import urllib
> > >>
> > >> data = urllib.urlencode({'data':'data1'})
> > >> conn = httplib.HTTPConnection(myipaddr)
> > >> headers = {"Content-type":"application/x-www-form-urlencoded",
> > >>                 "Accept":"text/plain",
> > >>                  "Content-Length:":len(data)}
> > >> h.request('POST','/',data,headers)
> > >>
> > >> res = h.getresponse()
> > >> print r.status,r.reason
> > >>
> > >> server side code(view.py):
> > >>
> > >> from django.shortcuts import render
> > >> from django.views.decorators.csrf import csrf_exempt
> > >> from django.http import HttpResponse
> > >> from django.conf.urls import url
> > >> from django.template import loader
> > >> from django.utils.timezone import utc
> > >> from django.template import Context, Template
> > >> from django.template.loader import get_template
> > >> from django.shortcuts import render_to_response
> > >> from django.template import RequestContext
> > >> from myapp.models import Temperature
> > >> from myapp import models
> > >> import socket , select
> > >> import os
> > >> import datetime
> > >> socktetList=[]
> > >>
> > >>
> > >> @csrf_exempt
> > >> def myview(request):
> > >>     if request.method == 'POST':
> > >>         return HttpResponse("%s %s" % (request.method, request.body))
> > >> #print POST body
> > >>     else:
> > >>         return HttpResponse("%s %s" % (request.method, request.body))
> > >>
> > >> on the client side i get "200 OK"(everything is ok)
> > >> but when i open my browser it return "GET",
> > >>
> > >> i want it to return or display POST DATA.
> > >>
> > >> how can i do that??
> > >> please help
> > >>
> > >>
> > >>
> > >> On Thu, May 7, 2015 at 4:13 PM, Thomas Levine <[email protected]>
> wrote:
> > >>
> > >>> On 07 May 16:00, steve malise wrote:
> > >>> > 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)"
> > >>>
> > >>> This is because
> > >>>
> > >>> On 07 May 11:42, Tom Evans wrote:
> > >>> > Eurgh. Your hand-crafted HTTP request is not a valid request. Use
> one
> > >>> > of the http libraries built in to python:
> > >>>
> > >>> You can find here some directions on forming the request validly,
> > >>> http://www.w3.org/Protocols/Specs.html
> > >>>
> > >>> as you apparently don't want to use any of the libraries below.
> > >>>
> > >>> On 07 May 16:00, steve malise wrote:
> > >>> > urllib2:
> > >>> > https://docs.python.org/2/howto/urllib2.html#data
> > >>> >
> > >>> > httplib:
> > >>> > https://docs.python.org/2/library/httplib.html#examples
> > >>> >
> > >>> > or use a 3rd party library that wraps those in a more pleasing
> > >>> interface:
> > >>> >
> > >>> > requests:
> > >>> > http://docs.python-requests.org/en/latest/
> > >>>
> > >>> Using one of the above-listed libraries would still accomplish what
> you
> > >>> are trying to do, as you described here,
> > >>>
> > >>> On 07 May 16:00, steve malise 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".
> > >>>
> > >>> so I suspect that you are doing something more that we missed.
> Perhaps
> > >>> you could tell us why you want to do this?
> > >>>
> > >>> --
> > >>> 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 [email protected].
> > >>> To post to this group, send email to [email protected].
> > >>> 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/20150507141332.GA27942%40d1stkfactory
> > >>> .
> > >>> For more options, visit https://groups.google.com/d/optout.
> > >>>
> > >>
> > >>  --
> > >> 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 [email protected].
> > >> To post to this group, send email to [email protected].
> > >> 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/CACwh%3D0zjAYKjmyTJTWcucTyLM_iVaLokcgqREZpXgzp7e_GEGw%40mail.gmail.com
> > >> <
> https://groups.google.com/d/msgid/django-users/CACwh%3D0zjAYKjmyTJTWcucTyLM_iVaLokcgqREZpXgzp7e_GEGw%40mail.gmail.com?utm_medium=email&utm_source=footer
> >
> > >> .
> > >> For more options, visit https://groups.google.com/d/optout.
> > >>
> > >
> > >  --
> > > 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 [email protected].
> > > To post to this group, send email to [email protected].
> > > 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/CAOs3Lp5N5RaBE7VRazeeA3gfc0Ccc5pRO7MNzCe-Z_rTr1Nsnw%40mail.gmail.com
> > > <
> https://groups.google.com/d/msgid/django-users/CAOs3Lp5N5RaBE7VRazeeA3gfc0Ccc5pRO7MNzCe-Z_rTr1Nsnw%40mail.gmail.com?utm_medium=email&utm_source=footer
> >
> > > .
> > >
> > > For more options, visit https://groups.google.com/d/optout.
> > >
> >
> > --
> > 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 [email protected].
> > To post to this group, send email to [email protected].
> > 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/CACwh%3D0zKZrqHovzc%3DY0MAaBp21k9YvbAHqCBFdwH9knx8vr9LA%40mail.gmail.com
> .
> > For more options, visit https://groups.google.com/d/optout.
>
>
> --
> Jani Tiainen
>
> --
> 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 [email protected].
> To post to this group, send email to [email protected].
> 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/20150511163147.3d10504d%40jns42-l.w2k.keypro.fi
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 [email protected].
To post to this group, send email to [email protected].
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/CACwh%3D0z1ZTNt7BcyuQUqv5mopgC5Py4HgwWiSZjOn%2Bq3TFp2DA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to