摘要:
from typing import Union from fastapi import Depends, FastAPI app = FastAPI() ''' 嵌套注入 - 路径函数get_name需要的形参`username_or_nickname`有依赖条件,所以FastAPI会调用 `us 阅读全文
摘要:
from fastapi import FastAPI, Depends app = FastAPI(title="依赖注入") ''' 依赖注入 - 共享一块相同逻辑的代码块 - 共享数据库连接 - 权限认证,登录状态认证 ''' BOOKS = [{"id": i, "name": f"book 阅读全文
摘要:
import typing from fastapi import FastAPI, Form, File, UploadFile from pydantic import BaseModel app = FastAPI(title="注册接口") ''' 1. 需要输入 账号 密码 头像 ''' 阅读全文
摘要:
import typing from fastapi import FastAPI, File, UploadFile app = FastAPI(title="Form表单") ''' 上传多个文件 ''' @app.post("/files",summary="通过内存缓存上传多个文件") de 阅读全文
摘要:
import typing from fastapi import FastAPI, File, UploadFile app = FastAPI(title="Form表单") ''' 上传文件为可选项 ''' @app.post("/upload_large_file", summary="上传 阅读全文
摘要:
from fastapi import FastAPI,Form,File,UploadFile app = FastAPI(title="Form表单") ''' Form表单接收数据 ''' @app.post("/login",summary="登录") def login(username 阅读全文
摘要:
import typing from fastapi import FastAPI, Query, HTTPException, status from fastapi.encoders import jsonable_encoder from pydantic import BaseModel a 阅读全文