parsers.py 439 B

1234567891011121314151617
  1. from rest_framework.parsers import BaseParser
  2. class GZHParser(BaseParser):
  3. media_type = "text/xml"
  4. def parse(self, stream, media_type=None, parser_context=None):
  5. cont = stream.read().decode('utf-8')
  6. return cont
  7. class JsonParser(BaseParser):
  8. media_type = "application/json"
  9. def parse(self, stream, media_type=None, parser_context=None):
  10. cont = stream.read().decode('utf-8')
  11. return cont