client side code: data = "message" try: clsocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) clsocket.connect(('192.168.2.2', 8000)) print("Connection has been Made") clsocket.send("POST / HTTP/1.1 "+ data) clsocket.close() except: print("ERROR:Connection is not established")
Django code(view.py) def RandomValues(request): template = get_template('TIME TABLE.html') s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) try: s.bind(('192.168.2.2',8000)) s.listen(5) socketList.append(s) except: return HttpResponse("Unable to bind ") while 1: readyToread,readyTowrite,inError = select.select(socketList,[],[],1) for sock in readyToread: if sock == s: sockfd, addr = s.accept() socketList.append(sockfd) else: data = sock.recv(4096) message = data.decode("utf-8") return HttpResponse(message) On my command prompt it says: [07/May/2015 10:06:21]code 400, message Bad request syntax ('POST / HTTP/1.1 message') [07/May/2015 10:06:21]"POST / HTTP/1.1 message" 400 - Even if i remove "POST / HTTP/1.1",i still get this error please help i am new to Django -- 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+unsubscr...@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/12ab40fa-b80f-4f35-ab5a-75530e9eca03%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.