old_contents: #!/usr/bin/env python
  # coding: utf-8
  
  # Reference: https://gist.github.com/bradmontgomery/2219997
  """
  Very simple HTTP server in python.
  Usage::
      ./dummy-web-server.py [<port>]
  Send a GET request::
      curl http://localhost
  Send a HEAD request::
      curl -I http://localhost
  Send a POST request::
      curl -d "foo=bar&bin=baz" http://localhost
  """
  from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
  
  class MyServer(BaseHTTPRequestHandler):
      def _set_headers(self):
          self.send_response(200)
          self.send_header('Content-type', 'text/html')
          self.end_headers()
  
      def do_GET(self):
          self._set_headers()
          self.wfile.write("<html><body><h1>hi!</h1></body></html>")
  
      def do_HEAD(self):
          self._set_headers()
  
      def do_POST(self):
          content_length = int(self.headers['Content-Length']) # <--- Gets the size of data
          post_data = self.rfile.read(content_length) # <--- Gets the data itself
          self._set_headers()
          self.wfile.write("<html><body><h1>%s!</h1></body></html>" % post_data)
          print post_data
  
          self.bot.send_msg(u'测试账号', post_data)
  
  def run(bot, server_class=HTTPServer, handler_class=MyServer, port=8888):
      server_address = ('', port)
      httpd = server_class(server_address, handler_class)
      httpd.bot = bot
      print 'Starting httpd...'
      httpd.serve_forever()
  
  if __name__ == "__main__":
      from sys import argv
  
      if len(argv) == 2:
          run(port=int(argv[1]))
      else:
          run()
  
  
new_contents: #!/usr/bin/env python
  # coding: utf-8
  
  # Reference: https://gist.github.com/bradmontgomery/2219997
  """
  Very simple HTTP server in python.
  Usage::
      ./dummy-web-server.py [<port>]
  Send a GET request::
      curl http://localhost
  Send a HEAD request::
      curl -I http://localhost
  Send a POST request::
      curl -d "foo=bar&bin=baz" http://localhost
  """
  from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
  
  class MyServer(BaseHTTPRequestHandler):
      def _set_headers(self):
          self.send_response(200)
          self.send_header('Content-type', 'text/html')
          self.end_headers()
  
      def do_GET(self):
          self._set_headers()
          self.wfile.write("<html><body><h1>hi!</h1></body></html>")
  
      def do_HEAD(self):
          self._set_headers()
  
      def do_POST(self):
          content_length = int(self.headers['Content-Length']) # <--- Gets the size of data
          post_data = self.rfile.read(content_length) # <--- Gets the data itself
          self._set_headers()
          self.wfile.write("<html><body><h1>%s!</h1></body></html>" % post_data)
          print post_data
  
          self.bot.send_msg(u'测试账号', post_data)
  
  def run(bot, server_class=HTTPServer, handler_class=MyServer, port=8888):
      server_address = ('', port)
      httpd = server_class(server_address, handler_class)
      handler_class.bot = bot
      print 'Starting httpd...'
      httpd.serve_forever()
  
  if __name__ == "__main__":
      from sys import argv
  
      if len(argv) == 2:
          run(port=int(argv[1]))
      else:
          run()
  
  
subject: add the bot into the handler rather than httpd server