async def analyze(request): img_data = await request.form() img_bytes = await (img_data['file'].read()) img = open_image(BytesIO(img_bytes)) prediction = learn.predict(img)[0] return JSONResponse({'result': str(prediction)})
response.update({"flag": manipulator_flag}) return response else: return JSONResponse( status_code=403, content={ "message": "He's not a Tech Commander! Meddling with Power Plant! Get him to KGB!!!" }) @router.get("/{key}/reset_progress") async def reset_progress(key: str): if commander := next(filter(lambda c: c.uuid == key, commanders), None): commander = Commander(commander.name) reactor_index = reactors.index(ReactorCore(commander.uuid)) reactors[reactor_index] = ReactorCore(commander.uuid) return JSONResponse( status_code=status.HTTP_200_OK, content={ "message": "Your reactor is good as new!", "flag": "${flag_you_didnt_see_the_graphite_because_its_not_there}" }) else: return JSONResponse(status_code=status.HTTP_400_BAD_REQUEST, content={ "message": "No such Commander!", "flag": "${flag_atomna_elektrostancja_erector}" })
async def hello(request): return JSONResponse({"hello": "world"})
async def list_users(request): users = await http_client.fetch_users_async() return JSONResponse({"data": users})
async def http_error_handler(_: Request, exc: HTTPException) -> JSONResponse: return JSONResponse({"errors": [exc.detail]}, status_code=exc.status_code)
async def http_exception(request, exc): return JSONResponse({"error": exc.detail}, status_code=exc.status_code)
async def get(self, request): return JSONResponse({'result': 'OK'})