mirror of
https://github.com/kennethreitz/responder.git
synced 2026-06-05 23:00:17 +00:00
i got it dude
This commit is contained in:
@@ -3,21 +3,24 @@ import json
|
||||
|
||||
|
||||
def format_form(r, encode=False):
|
||||
return r._wz.form
|
||||
if not encode:
|
||||
return r._wz.form
|
||||
|
||||
|
||||
def format_yaml(r, encode=False):
|
||||
if encode:
|
||||
return yaml.load(r.content)
|
||||
else:
|
||||
r.headers.update({"Content-Type": "application/x-yaml"})
|
||||
return yaml.dump(r.media)
|
||||
else:
|
||||
return yaml.load(r.content)
|
||||
|
||||
|
||||
def format_json(r, encode=False):
|
||||
if encode:
|
||||
return json.loads(r.content)
|
||||
else:
|
||||
r.headers.update({"Content-Type": "application/json"})
|
||||
return json.dumps(r.media)
|
||||
else:
|
||||
return json.loads(r.content)
|
||||
|
||||
|
||||
def get_formats():
|
||||
|
||||
+1
-5
@@ -99,11 +99,7 @@ class Response:
|
||||
|
||||
for format in self.formats:
|
||||
if self.req.accepts(format):
|
||||
return (
|
||||
self.formats[format](self),
|
||||
self.mimetype or "application/x-yaml",
|
||||
{"Content-Type": "application/x-yaml"},
|
||||
)
|
||||
return self.formats[format](self, encode=True), None, {}
|
||||
|
||||
# Default to JSON anyway.
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user