How to use the fastapi.Form function in fastapi

To help you get started, we’ve selected a few fastapi examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tiangolo / fastapi / pending_tests / main.py View on Github external
def post_token(request_data: OAuth2PasswordRequestForm = Form(...)):
    data = request_data.parse()
    access_token = data.username + ":" + data.password
    return {"access_token": access_token}
github tiangolo / fastapi / tests / main_old.py View on Github external
def post_token(request_data: OAuth2PasswordRequestForm = Form(...)):
    data = request_data.parse()
    access_token = data.username + ":" + data.password
    return {"access_token": access_token}
github BMW-InnovationLab / BMW-YOLOv3-Inference-API-CPU / src / main / start.py View on Github external
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:
github tiangolo / fastapi / docs / tutorial / src / all / tutorial041.py View on Github external
async def create_file(*, file: bytes = File(...), token: str = Form(...)):
    return {"file_size": len(file), "token": token}
github erm / guitarlette / src / app.py View on Github external
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",
    )
github MrNaif2018 / bitcart / api / views.py View on Github external
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)
github tiangolo / fastapi / docs / tutorial / src / all / tutorial039.py View on Github external
async def login(*, username: str = Form(...), password: str = Form(...)):
    return {"username": username}
github tiangolo / fastapi / docs / src / request_forms_and_files / tutorial001.py View on Github external
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,
    }
github tweag / trustix / packages / trustix-nix-reprod / trustix_nix_reprod / app.py View on Github external
async def search_form(request: Request, term: str = Form(...)):
    return RedirectResponse(app.url_path_for("search", term=term), status_code=303)
github BMW-InnovationLab / BMW-YOLOv3-Inference-API-CPU / src / main / start.py View on Github external
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)