code: def generate(self):
                          
          answer = self.rand.randrange(self.max)
          answer = str(answer).zfill(self.digits)        
          image_data = self.image_generator.generate(answer)
          base64_captcha = base64.b64encode(image_data.getvalue()).decode("ascii")
          logging.debug('Generated captcha with answer: ' + answer)
          session['captcha_answer'] = answer
          return base64_captcha
docs: Generates and returns a numeric captcha image in base64 format. 
          Saves the correct answer in `session['captcha_answer']`
          Use later as:
  
          src = captcha.generate()
          <img src="{{src}}">