1

I'm coding a simple python server to hold logs throughout a company. The site presents change logs for upcoming projects for all teams. Each team has the option to edit their logs. The way I did this was by making a form with a TEXTAREA which they fill out and submit. However, I can't for the life of me figure out how to pull the value of the textarea into my server. Right now I have:

def do_POST(self):
    length = int(self.headers.getheader('content-length'))
    results = self.rfile.read(length).split("&")

This works fine if you're trying to pull the results of something like a radio button, checkbox, or textbox but when POSTing it returns the value of the TEXTAREA differently.

How do I get what's in the TEXTAREA into a variable on the python-server side?

SuperFamousGuy
  • 1,455
  • 11
  • 16

1 Answers1

0

I'm guessing that when you're getting the radio/checkbox/textbox values you're using a GET request, in which case the values will be sent as URL parameters. i.e.:

yoururl.com/bla.html?radioName=someValue&bla=hi

which you're using to retrieve the values. This is not the case with the POST request. As far as I know, how you grab the POSTed values will depend on what you're using to run the python server (I'm no pro on this subject). A good breakdown of reading POSTed values can be found with this question: How are POST and GET variables handled in Python?

Community
  • 1
  • 1
oli
  • 3,541
  • 1
  • 27
  • 34