上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 49 下一页
摘要: from typing import Union from fastapi import Depends, FastAPI app = FastAPI() ''' 嵌套注入 - 路径函数get_name需要的形参`username_or_nickname`有依赖条件,所以FastAPI会调用 `us 阅读全文
posted @ 2023-03-26 20:35 LeoShi2020 阅读(26) 评论(0) 推荐(0) 编辑
摘要: from fastapi import FastAPI, Depends app = FastAPI(title="依赖注入") ''' 依赖注入 - 共享一块相同逻辑的代码块 - 共享数据库连接 - 权限认证,登录状态认证 ''' BOOKS = [{"id": i, "name": f"book 阅读全文
posted @ 2023-03-26 20:02 LeoShi2020 阅读(72) 评论(0) 推荐(0) 编辑
摘要: import typing from fastapi import FastAPI, Form, File, UploadFile from pydantic import BaseModel app = FastAPI(title="注册接口") ''' 1. 需要输入 账号 密码 头像 ''' 阅读全文
posted @ 2023-03-26 18:25 LeoShi2020 阅读(19) 评论(0) 推荐(0) 编辑
摘要: import typing from fastapi import FastAPI, File, UploadFile app = FastAPI(title="Form表单") ''' 上传多个文件 ''' @app.post("/files",summary="通过内存缓存上传多个文件") de 阅读全文
posted @ 2023-03-26 17:57 LeoShi2020 阅读(37) 评论(0) 推荐(0) 编辑
摘要: import typing from fastapi import FastAPI, File, UploadFile app = FastAPI(title="Form表单") ''' 上传文件为可选项 ''' @app.post("/upload_large_file", summary="上传 阅读全文
posted @ 2023-03-26 17:38 LeoShi2020 阅读(71) 评论(0) 推荐(0) 编辑
摘要: from fastapi import FastAPI,Form,File,UploadFile app = FastAPI(title="Form表单") ''' Form表单接收数据 ''' @app.post("/login",summary="登录") def login(username 阅读全文
posted @ 2023-03-26 17:04 LeoShi2020 阅读(162) 评论(0) 推荐(0) 编辑
摘要: import typing from fastapi import FastAPI, Query, HTTPException, status from fastapi.encoders import jsonable_encoder from pydantic import BaseModel a 阅读全文
posted @ 2023-03-26 12:51 LeoShi2020 阅读(12) 评论(0) 推荐(0) 编辑
摘要: import typing import json from fastapi import FastAPI, Response from fastapi.encoders import jsonable_encoder from datetime import datetime from pydan 阅读全文
posted @ 2023-03-25 17:41 LeoShi2020 阅读(148) 评论(0) 推荐(0) 编辑
摘要: import typing from fastapi import FastAPI, Response from fastapi.responses import JSONResponse from pydantic import BaseModel app = FastAPI() ''' pyda 阅读全文
posted @ 2023-03-25 17:25 LeoShi2020 阅读(90) 评论(0) 推荐(0) 编辑
摘要: import typing from fastapi import FastAPI, Response from fastapi.responses import JSONResponse from pydantic import BaseModel app = FastAPI() ''' 过滤响应 阅读全文
posted @ 2023-03-25 15:45 LeoShi2020 阅读(123) 评论(0) 推荐(0) 编辑
上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 49 下一页