title: New to Python, trying to create a program that prints Gmail to a web page
body: <p>This is my code currently, I am using Google Cloud SDK and Python 2.7:</p>
  
  <pre><code>import webapp2
  import smtplib
  import time
  import imaplib
  import email
  
  
  class ReadMail(webapp2.RequestHandler):
      def get(self):
  
          mail = imaplib.IMAP4_SSL(imap.gmail.com)
          mail.login('xxx@gmail.com','xxx')
          mail.select('inbox')
  
          type, data = mail.search(None, 'ALL')
          mail_ids = data[0]
  
          id_list = mail_ids.split()   
          first_email_id = int(id_list[0])
          latest_email_id = int(id_list[-1])
  
  
          for i in range(latest_email_id,first_email_id, -1):
              typ, data = mail.fetch(i, '(RFC822)' )
  
              for response_part in data:
                  if isinstance(response_part, tuple):
                      msg = email.message_from_string(response_part[1])
                      email_subject = msg['subject']
                      email_from = msg['from']
                      self.response.headers['Content-Type'] = 'text/plain'
                      self.response.write('Hello World?')
                      self.response.write('From :') + email_from + '\n'
                      self.response.write('Subject :') + email_subject + '\n'
  
  
  
  
  app = webapp2.WSGIApplication([
      ('/', ReadMail),
  ], debug=True)
  </code></pre>
  
  <p>However I get this error, and the web-page does not load (HTML 500 error):</p>
  
  <pre><code>ERROR    2018-06-14 07:30:02,217 wsgi.py:279]
  Traceback (most recent call last):
    File "C:\Users\XXX\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\runtime\wsgi.py", line 267, in Handle
      result = handler(dict(self._environ), self._StartResponse)
  TypeError: 'module' object is not callable
  INFO     2018-06-14 10:30:02,878 module.py:846] default: "GET / HTTP/1.1" 500 -
  INFO     2018-06-14 10:30:08,711 module.py:414] [default] Detected file changes:
    hello.pyc
  </code></pre>
  
  <p>I see the issue is with calling the modules, but since I am completely new to python it is hard for me to understand how this works. Any help would be appreciated!</p>
  
  <p><strong>EDIT</strong>
  If I remove the <code>'Request.Handler'</code> from <code>class ReadMail(webapp2.RequestHandler)</code>, I get this error instead:</p>
  
  <pre><code> File "C:\Users\xxx\desktop\pythontest\demo\hello.py", line 8, in &lt;module&gt;
      class ReadMail(webapp2):
  TypeError: Error when calling the metaclass bases
      module.__init__() takes at most 2 arguments (3 given)
  INFO     2018-06-14 11:00:42,963 module.py:846] default: "GET / HTTP/1.1" 500 -
  </code></pre>