def decodeJWTView(request):
  """Processes POST request and sends decoded JWT as pretty printed JSON object.

  Args:
    request: A HTTP request object.

  Returns:
    A pretty printed JSON object if valid jwt is present, returns a HTTP 404
    otherwise.
  """
  input_jwt = request.POST.get('jwt', None)
  if not input_jwt:
    webapp2.abort(404)

  try:
    input_jwt = unicodedata.normalize(NORMAL_FORM, input_jwt).encode(
        'ascii', 'ignore')
    # Append extra characters to make original string base 64 decodable.
    input_jwt += '=' * (4 - (len(input_jwt) % 4))
    decoded_jwt = base64.urlsafe_b64decode(input_jwt)
  except JSONDecodeError as e:
    result = {'error': True}
    webapp2.abort(404)
  else:
    decoded_jwt = json.loads(decoded_jwt)
    return webapp2.Response(json.dumps(decoded_jwt, indent=8))
dataset/ETHPy150Open android-pay/jwt-decoder-python/jwtdecoder.py/decodeJWTView/original