def get_param(req, name, default=None):
 value = req.params.get(name, default)
 if (value and (not isinstance(value, six.text_type))):
  try:
   value.decode('utf8')
  except UnicodeDecodeError:
   raise HTTPBadRequest(request=req, content_type='text/plain', body=('"%s" parameter not valid UTF-8' % name))
 return value

def get_param ( req , name , default = None ) : value = req . params . get ( name , default ) if ( value and ( not isinstance ( value , six . text_type ) ) ) : try : value . decode ( 'utf8' ) except UnicodeDecodeError : raise HTTPBadRequest ( request = req , content_type = 'text/plain' , body = ( '"%s" parameter not valid UTF-8' % name ) ) return value
get parameters from an http request ensuring proper handling utf-8 encoding .