title: Trying to do a DELETE method in python server
body: <p>it's the first time I'm working (or trying) with Python. I would like to POST/GET and DELETE.
  POST and GET is working good but I got a big headache when I try to delete something that I have posted. Could you please give some enlightening? 
  Thanks in advance!</p>
  
  <pre><code>import time
  import BaseHTTPServer
  import cgi
  
  
  HOST_NAME = '0.0.0.0' 
  PORT_NUMBER = 8000 
  
  datastorage = []
  
  class MyHandler(BaseHTTPServer.BaseHTTPRequestHandler):
      def do_HEAD(s):
          s.send_response(200)
          s.send_header("Content-type", "text/html")
          s.end_headers()
  
      def do_POST(s):
          s.send_response(200)
          s.wfile.write("Ok")
          contentLengthAsList = s.headers.getheaders('content-length')
          contentLengthAsInt = int(contentLengthAsList[0])
  
          x = cgi.parse_qs(s.rfile.read(contentLengthAsInt), keep_blank_values=1)
          datastorage.append(x['myHttpData'][0])
  
          print(datastorage)
          s.end_headers()
  
      def do_GET(s):
          """Respond to a GET request."""
          s.send_response(200)
          s.send_header("Content-type", "text/html")
          s.end_headers()
          s.wfile.write("&lt;html&gt;&lt;head&gt;&lt;title&gt;MyPage&lt;/title&gt;&lt;/head&gt;")
          s.wfile.write("&lt;body&gt;&lt;p&gt;The messages&lt;/p&gt;")
          for x in range(len(datastorage)):
            s.wfile.write("&lt;form action='/' method='DELETE'&gt;"+datastorage[x]+"&lt;input type='hidden'     name='index' value='x'/&gt;&lt;input type='submit' value='Remove'/&gt;&lt;/form&gt;&lt;/br&gt;")  
          s.wfile.write("&lt;/body&gt;&lt;/html&gt;")
  
      def do_DELETE(s):
          global datastorage
          print 'That is working'
          contentLengthAsList = s.headers.getheaders('content-length')    
          contentLengthAsInt = int(contentLengthAsList[0])
  
          x = cgi.parse_qs(s.rfile.read(contentLengthAsInt), keep_blank_values=1)
          datastorage = datastorage.pop(x)
  
          s.send_response(301) #Moved Permanently
          s.send_header("location", "/")
          s.end_headers()
  
  
  
  if __name__ == '__main__':
       server_class = BaseHTTPServer.HTTPServer
       httpd = server_class((HOST_NAME, PORT_NUMBER), MyHandler)
       print time.asctime(), "Server Starts - %s:%s" % (HOST_NAME, PORT_NUMBER)
       try:
            httpd.serve_forever()
       except KeyboardInterrupt:
            pass
       httpd.server_close()
       print time.asctime(), "Server Stops - %s:%s" % (HOST_NAME, PORT_NUMBER)`
  </code></pre>