首页
博客
源码
资源
博客
源码
写文章
发布博客
发布资源
登录
X
fastapi
相关资讯
热门
最新
代码人生
01-01 08:00
代码人生
FastAPI(11)- 函数参数类型是列表,但不使用 typing 中的 List,而使用 list,会怎么样?
FastAPI(11)- 函数参数类型是列表,但不使用 typing 中的 List,而使用 list,会怎么样? 使用 typing 中的 List、Set、Tuple 的栗子 from typing import Optional import uvicorn from fastapi import FastAPI, Body from typing import List, Tuple, Set app = FastAPI() @app.put("
76
代码人生
01-01 08:00
代码人生
FastAPI 学习之路(一)fastapi--高性能web开发框架
FastAPI 学习之路(一)fastapi--高性能web开发框架 fastapi是高性能的web框架。他的主要特点是:- 快速编码- 减少人为bug- 直观- 简易- 具有交互式文档 - 高性能 - 基于API的开放标准 支持python 3.6版本。 安装 pip install fastapi 安装部署包 pip install
74
代码人生
01-01 08:00
代码人生
FastAPI hello-word
FastAPI hello-word from typing import Optional from fastapi import FastAPI app = FastAPI() @app.get("/") def read_root(): return {"Hello": "World"} @app.get("/items/{item_id}") def read_
71
代码人生
01-01 08:00
代码人生
fastapi小技巧
fastapi小技巧 1、定制文档生成: 参见 fastapi/applycations.py 中的setup. /docs 把所有的路径routes 都包含进去了。参考实现根据tag 实现文档生成。 要先生成docs 需要的openapi_url。(其中get_openapi 是fastapi.openapi.utils 内部的函数) @app
69
代码人生
01-01 08:00
代码人生
fastapi 挂载静态文件夹
fastapi 挂载静态文件夹 from fastapi.staticfiles import StaticFiles app.mount(path=‘/coronavirus/‘,app=StaticFiles(directory=‘ ./coronavirus/static‘, name=‘static‘)) 原文:https://www.cnblogs.
69
代码人生
01-01 08:00
代码人生
FastApi之 路径操作中实现依赖
FastApi之 路径操作中实现依赖 # 如何通过路径参数配置依赖,如何在路径中使用依赖, --- 路径操作装饰器中的多依赖 --->类似继承 # 写没有返回值的子依赖 async def verify_token(x_token: str = Header(..., convert_underscores=True)): """ 验证x_token值 是否存在
68
代码人生
01-01 08:00
代码人生
fastapi上传文件之File,UploadFile
fastapi上传文件之File,UploadFile File类 上传单个文件 from fastapi import File from typing import List @app04.post(‘single_file‘) async def single_file(file: bytes = File(...)) return {‘filesize‘: len(fil
67
代码人生
01-01 08:00
代码人生
FastAPI系列 路径操作装饰器中的依赖项
FastAPI系列 路径操作装饰器中的依赖项 一、路径操作装饰器中添加依赖项 在某些场景中你可能不需要在路径操作函数中去接收依赖项的返回值,或者这个依赖项根本没有返回值。但是你仍然需要去执行这些依赖项。 对于这些场景,不要通过在路径操作函数中去声明Depends参数,你可以在路径操作装饰器中去添加一个dependencies的列表。 比如: from fastapi import Depends,
66
代码人生
01-01 08:00
代码人生
fastapi用法
fastapi用法 POST GET请求方法: import time import uvicorn from fastapi import FastAPI, Body from pydantic import BaseModel app = FastAPI() # POST请求 @app.post("/extraction/article/v1/getRegion")
65
代码人生
01-01 08:00
代码人生
FastAPI系列 子依赖
FastAPI系列 子依赖 一、子依赖 在依赖注入系统中可以构建任意深度的依赖关系,FastAPI会负责进行解析。而一个依赖项依赖于另一个依赖项,那么另一个依赖项就被称为子依赖。比如: from typing import Optional from fastapi import Cookie, Depends, FastAPI app = FastAPI() def qu
61
«
1
2
3
4
5
6
»