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()
|
context_value = req.preserve()
|
||||||
|
|
||||||
# get all incoming data and parses as json
|
# get all incoming data and parses as json
|
||||||
body = await res.get_json()
|
body = res.get_json()
|
||||||
|
|
||||||
query = body["query"]
|
query = body["query"]
|
||||||
variables = body.get("variables", None)
|
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):
|
async def upload_json(res, req):
|
||||||
print(f"Posted to {req.get_url()}")
|
print(f"Posted to {req.get_url()}")
|
||||||
# await all the data and parses as json, returns None if fail
|
# await all the data and parses as json, returns None if fail
|
||||||
info = await res.get_json()
|
info = res.get_json()
|
||||||
|
|
||||||
print(info)
|
print(info)
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ async def upload_multiple(res, req):
|
||||||
content_type = req.get_header("content-type")
|
content_type = req.get_header("content-type")
|
||||||
# we can check the Content-Type to accept multiple formats
|
# we can check the Content-Type to accept multiple formats
|
||||||
if content_type == "application/json":
|
if content_type == "application/json":
|
||||||
data = await res.get_json()
|
data = res.get_json()
|
||||||
elif content_type == "application/x-www-form-urlencoded":
|
elif content_type == "application/x-www-form-urlencoded":
|
||||||
data = await res.get_form_urlencoded()
|
data = await res.get_form_urlencoded()
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -1585,8 +1585,8 @@ class AppResponse:
|
||||||
except Exception:
|
except Exception:
|
||||||
return None # invalid encoding
|
return None # invalid encoding
|
||||||
|
|
||||||
async def get_json(self):
|
def get_json(self):
|
||||||
data = await self.get_data()
|
data = self.get_data()
|
||||||
try:
|
try:
|
||||||
return self.app._json_serializer.loads(data.getvalue().decode("utf-8"))
|
return self.app._json_serializer.loads(data.getvalue().decode("utf-8"))
|
||||||
except Exception:
|
except Exception:
|
||||||
|
|
Ładowanie…
Reference in New Issue