當前位置: 首頁>>代碼示例>>Python>>正文


Python fastapi.Form方法代碼示例

本文整理匯總了Python中fastapi.Form方法的典型用法代碼示例。如果您正苦於以下問題:Python fastapi.Form方法的具體用法?Python fastapi.Form怎麽用?Python fastapi.Form使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在fastapi的用法示例。


在下文中一共展示了fastapi.Form方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: detect_custom

# 需要導入模塊: import fastapi [as 別名]
# 或者: from fastapi import Form [as 別名]
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:
		error_logging.error(model + ' ' + str(e))
		return ApiResponse(success=False, error='unexpected server error') 
開發者ID:BMW-InnovationLab,項目名稱:BMW-TensorFlow-Inference-API-CPU,代碼行數:21,代碼來源:start.py

示例2: create_site_template

# 需要導入模塊: import fastapi [as 別名]
# 或者: from fastapi import Form [as 別名]
def create_site_template(
    db: Session = Depends(get_db),
    name: str = Form(...),
    zip_file: UploadFile = File(..., alias='zipFile'),
    remark: Union[str, None] = Form(None),
):
    site_template_profile = dict(
        name=name,
        remark=remark,
        zip_file_name=zip_file.filename,
        zip_file_content=await zip_file.read()
    )
    created_data = crud_site_template.create_site_template(
        db, site_template_profile
    )
    return dict(result=created_data) 
開發者ID:QAX-A-Team,項目名稱:LuWu,代碼行數:18,代碼來源:config.py

示例3: detect_robotron

# 需要導入模塊: import fastapi [as 別名]
# 或者: from fastapi import Form [as 別名]
def detect_robotron(request: Request, background_tasks: BackgroundTasks, model: str = Form(...), image: UploadFile = File(...)):
	"""
	Performs a prediction for a specified image using one of the available models.
	:param request: Used if background tasks was enabled
	:param background_tasks: Used if background tasks was enabled
	:param model: Model name or model hash
	:param image: Image file
	:return: Model's Bounding boxes
	"""
	draw_boxes = False
	predict_batch = False
	try:
		request_start = time.time()
		output = await dl_service.run_model(model, image, draw_boxes, predict_batch)
		# background_tasks.add_task(metrics_collector,'detect',image, output, request, request_start)
		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:
		error_logging.error(model+' '+str(e))
		return ApiResponse(success=False, error='unexpected server error') 
開發者ID:BMW-InnovationLab,項目名稱:BMW-TensorFlow-Training-GUI,代碼行數:25,代碼來源:start.py

示例4: get_labels_custom

# 需要導入模塊: import fastapi [as 別名]
# 或者: from fastapi import Form [as 別名]
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) 
開發者ID:BMW-InnovationLab,項目名稱:BMW-TensorFlow-Inference-API-CPU,代碼行數:9,代碼來源:start.py

示例5: post_form_param_list

# 需要導入模塊: import fastapi [as 別名]
# 或者: from fastapi import Form [as 別名]
def post_form_param_list(items: list = Form(...)):
    return items 
開發者ID:tiangolo,項目名稱:fastapi,代碼行數:4,代碼來源:test_forms_from_non_typing_sequences.py

示例6: post_form_param_set

# 需要導入模塊: import fastapi [as 別名]
# 或者: from fastapi import Form [as 別名]
def post_form_param_set(items: set = Form(...)):
    return items 
開發者ID:tiangolo,項目名稱:fastapi,代碼行數:4,代碼來源:test_forms_from_non_typing_sequences.py

示例7: post_form_param_tuple

# 需要導入模塊: import fastapi [as 別名]
# 或者: from fastapi import Form [as 別名]
def post_form_param_tuple(items: tuple = Form(...)):
    return items 
開發者ID:tiangolo,項目名稱:fastapi,代碼行數:4,代碼來源:test_forms_from_non_typing_sequences.py

示例8: create_file

# 需要導入模塊: import fastapi [as 別名]
# 或者: from fastapi import Form [as 別名]
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,
    } 
開發者ID:tiangolo,項目名稱:fastapi,代碼行數:10,代碼來源:tutorial001.py

示例9: login

# 需要導入模塊: import fastapi [as 別名]
# 或者: from fastapi import Form [as 別名]
def login(username: str = Form(...), password: str = Form(...)):
    return {"username": username} 
開發者ID:tiangolo,項目名稱:fastapi,代碼行數:4,代碼來源:tutorial001.py

示例10: create_c2_profile

# 需要導入模塊: import fastapi [as 別名]
# 或者: from fastapi import Form [as 別名]
def create_c2_profile(
    db: Session = Depends(get_db),
    name: str = Form(...),
    profile: UploadFile = File(...),
    remark: str = Form(None),
):
    c2_profile_obj = C2ProfileCreate(
        name=name,
        remark=remark,
        profile_name=profile.filename,
        profile_content=await profile.read()
    )
    created_data = crud_c2.create(db, obj_in=c2_profile_obj)
    return dict(result=created_data) 
開發者ID:QAX-A-Team,項目名稱:LuWu,代碼行數:16,代碼來源:config.py

示例11: get_labels_robotron

# 需要導入模塊: import fastapi [as 別名]
# 或者: from fastapi import Form [as 別名]
def get_labels_robotron(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_robotron(model)
####robotron specific#### 
開發者ID:BMW-InnovationLab,項目名稱:BMW-TensorFlow-Training-GUI,代碼行數:10,代碼來源:start.py


注:本文中的fastapi.Form方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。