Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async def token(request):
data = await request.json()
return web.json_response({'result': data.get('uid_hash')})
request.cirrina.db_session.add(build)
request.cirrina.db_session.commit()
await build.build_added()
token = uuid.uuid4()
buildtask = BuildTask(build=build, task_id=str(token))
request.cirrina.db_session.add(buildtask)
request.cirrina.db_session.commit()
if git_ref == "":
args = {"buildlatest": [repo.id, build.id]}
else:
args = {"build": [build.id, repo.id, git_ref, git_branch]}
await request.cirrina.task_queue.put(args)
return web.json_response({"build_token": str(token)})
async def create_pet(request: web.Request) -> web.Response:
with openapi_context(request) as context:
new_pet = NewPet(
name=context.data["name"], tag=context.data.get("tag")
)
pet = new_pet.to_pet(len(request.app["pets"]) + 1)
request.app["pets"].append(pet)
return web.json_response(attr.asdict(pet))
async def wrapped(request, product, version):
try:
response = await task(product, version)
except Exception as e: # In case something went bad, we return an error status message
logger.exception(e)
body = {
'status': 'error',
'message': str(e)
}
if hasattr(e, 'url') and e.url is not None:
body['link'] = e.url
return web.json_response(body)
return web.json_response(response)
return wrapped
def prepare_response(data):
headers = {}
# TODO Do things with header here
return web.json_response(data, headers=headers, dumps=json.dumps)
async def handler(request):
await asyncio.sleep(0.01)
payload = {'name': 'service_e', 'host': host, 'port': port, 'children': []}
return web.json_response(payload)
async def rest_feutil_fan4_hdl(self, request):
return web.json_response(
rest_feutil.get_feutil_fan4_data(), dumps=dumps_bytestr
)
include_handshake = body.get("include_handshake")
use_public_did = body.get("use_public_did")
multi_use = json.loads(request.query.get("multi_use", "false"))
oob_mgr = OutOfBandManager(context)
try:
invitation = await oob_mgr.create_invitation(
multi_use=multi_use,
attachments=attachments,
include_handshake=include_handshake,
use_public_did=use_public_did,
)
except (StorageNotFoundError, ValidationError, OutOfBandManagerError) as e:
raise web.HTTPBadRequest(reason=str(e))
return web.json_response(invitation.serialize())
async def wrapper(self, request, *args, **kwargs):
res = await func(self, request, *args, **kwargs)
response = web.json_response(data=res)
if response.content_length > COMPRESS_THRESHOLD:
response.enable_compress(force=ContentCoding.gzip)
return response
service = postbody["service"]
if service == "EcoMsgNew":
srvip = bumper.bumper_announce_ip
srvport = 5223
confserverlog.info(
"Announcing EcoMsgNew Server to bot as: {}:{}".format(
srvip, srvport
)
)
msgserver = {"ip": srvip, "port": srvport, "result": "ok"}
msgserver = json.dumps(msgserver)
msgserver = msgserver.replace(
" ", ""
) # bot seems to be very picky about having no spaces, only way was with text
return web.json_response(text=msgserver)
elif service == "EcoUpdate":
srvip = "47.88.66.164" # EcoVacs Server
srvport = 8005
confserverlog.info(
"Announcing EcoUpdate Server to bot as: {}:{}".format(
srvip, srvport
)
)
body = {"result": "ok", "ip": srvip, "port": srvport}
return web.json_response(body)
except Exception as e:
confserverlog.exception("{}".format(e))