0

I am trying to follow the answer to this question so that I can process HTTP GET input:

Processing HTTP GET input parameter on server side in python

but I get the error "self not defined" which makes sense because at no point is a function defined with self as a parameter. I'd assume that the person answering the question assumed that the context of the code they posted was understood by the person asking the question but this context is not clear to me.

here is the code from the question I linked above:

from urlparse import urlparse, parse_qs
query_components = parse_qs(urlparse(self.path).query)
imsi = query_components["imsi"] 
# query_components = { "imsi" : ["Hello"] }

notice the use of "self" in query = urlparse(self.path).query and parse_qs(urlparse(self.path).query)

I would like to know how to use this code provided, for example, if you could give a function using this code that I could copy into my program that would be sufficient or if you could provide an example of a fully function program that processes HTTP GET input in this way that would also be sufficient.

Thanks for the help

7
  • self is used inside a class if you can see the code in the link is inside a class MyHandler Commented Dec 27, 2017 at 5:28
  • how could i do this with out using a class? Commented Dec 27, 2017 at 5:28
  • just remove it, query = urlparse(path).query Commented Dec 27, 2017 at 5:29
  • ok, thanks I'll give that a try and if it works write that up in an answer and I'll accept it Commented Dec 27, 2017 at 5:31
  • I get the error "path not defined" Commented Dec 27, 2017 at 5:33

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.