kopia lustrzana https://github.com/cirospaciari/socketify.py
rodzic
63b1546bbb
commit
fe34019fd2
|
@ -55,7 +55,7 @@ def graphiql_from(Query, Mutation=None):
|
|||
context_value = req.preserve()
|
||||
|
||||
# get all incoming data and parses as json
|
||||
body = await res.get_json()
|
||||
body = res.get_json()
|
||||
|
||||
query = body["query"]
|
||||
variables = body.get("variables", None)
|
||||
|
|
|
@ -47,7 +47,7 @@ Similar to `res.get_data()`, `res.get_json()` will decode the json as dict.
|
|||
async def upload_json(res, req):
|
||||
print(f"Posted to {req.get_url()}")
|
||||
# await all the data and parses as json, returns None if fail
|
||||
info = await res.get_json()
|
||||
info = res.get_json()
|
||||
|
||||
print(info)
|
||||
|
||||
|
@ -79,7 +79,7 @@ async def upload_multiple(res, req):
|
|||
content_type = req.get_header("content-type")
|
||||
# we can check the Content-Type to accept multiple formats
|
||||
if content_type == "application/json":
|
||||
data = await res.get_json()
|
||||
data = res.get_json()
|
||||
elif content_type == "application/x-www-form-urlencoded":
|
||||
data = await res.get_form_urlencoded()
|
||||
else:
|
||||
|
|
|
@ -1585,8 +1585,8 @@ class AppResponse:
|
|||
except Exception:
|
||||
return None # invalid encoding
|
||||
|
||||
async def get_json(self):
|
||||
data = await self.get_data()
|
||||
def get_json(self):
|
||||
data = self.get_data()
|
||||
try:
|
||||
return self.app._json_serializer.loads(data.getvalue().decode("utf-8"))
|
||||
except Exception:
|
||||
|
|
Ładowanie…
Reference in New Issue