Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def post_token(request_data: OAuth2PasswordRequestForm = Form(...)):
data = request_data.parse()
access_token = data.username + ":" + data.password
return {"access_token": access_token}
def post_token(request_data: OAuth2PasswordRequestForm = Form(...)):
data = request_data.parse()
access_token = data.username + ":" + data.password
return {"access_token": access_token}
async def detect_custom(model: str = Form(...), image: UploadFile = File(...)):
"""
Performs a prediction for a specified image using one of the available models.
:param model: Model name or model hash
:param image: Image file
:return: Model's Bounding boxes
"""
draw_boxes = False
predict_batch = False
try:
output = await dl_service.run_model(model, image, draw_boxes, predict_batch)
error_logging.info('request successful;' + str(output))
return output
except ApplicationError as e:
error_logging.warning(model + ';' + str(e))
return ApiResponse(success=False, error=e)
except Exception as e:
async def create_file(*, file: bytes = File(...), token: str = Form(...)):
return {"file_size": len(file), "token": token}
def download(request: Request, content: str = Form(...)) -> StreamingResponse:
filename = f"guitarlette-{datetime.now().strftime('%Y-%m-%d-%H:%M:%S')}.txt"
return StreamingResponse(
BytesIO(content.encode()),
headers={"Content-Disposition": f"attachment; filename={filename}"},
media_type="text/plain",
)
async def patch_product(
model_id: int,
data: str = Form(...),
image: UploadFile = File(None),
user: models.User = Security(utils.AuthDependency(), scopes=["product_management"]),
):
return await process_edit_product(model_id, data, image, user)
async def login(*, username: str = Form(...), password: str = Form(...)):
return {"username": username}
async def create_file(
file: bytes = File(...), fileb: UploadFile = File(...), token: str = Form(...)
):
return {
"file_size": len(file),
"token": token,
"fileb_content_type": fileb.content_type,
}
async def search_form(request: Request, term: str = Form(...)):
return RedirectResponse(app.url_path_for("search", term=term), status_code=303)
def get_labels_custom(model: str = Form(...)):
"""
Lists the model's labels with their hashed values.
:param model: Model name or model hash
:return: A list of the model's labels with their hashed values
"""
return dl_service.get_labels_custom(model)