隐藏页面特效
摘要: 作用 提供获取对象信息的函数,如模块、类、方法、函数、回溯、帧对象和代码对象 类型检查 用于判断对象的类型(如函数,类,生成器等),常用函数 inspcet.isfunction(obj),检查是否为函数 inspect.isclass(obj),检查是否为类 inspect.ismethod(ob 阅读全文 »
posted @ 2025-03-03 02:21 我在路上回头看 阅读(3) 评论(0) 推荐(0) 编辑
摘要: HttpBasic基本认证 from fastapi import FastAPI, Depends from fastapi.security import HTTPBasic, HTTPBasicCredentials from fastapi.exceptions import HTTPExc 阅读全文 »
posted @ 2024-02-28 19:09 我在路上回头看 阅读(169) 评论(0) 推荐(0) 编辑
摘要: aioredis official website Install pip install aioredis Connect to redis from fastapi import FastAPI import aioredis app = FastAPI() @app.on_event('sta 阅读全文 »
posted @ 2024-02-28 19:04 我在路上回头看 阅读(1331) 评论(0) 推荐(0) 编辑
摘要: jwt认证 1.头部Header,主要是对jwt元数据的描述 { 'alg': 'HS256', 'typ': 'JWT' } 2.载荷playload,主要包含jwt信息需要传递的主体数据 { 'iss': 'jack', # 由jwt签发 'sub': 'jack', # 该jwt面向的用户组, 阅读全文 »
posted @ 2024-02-28 19:00 我在路上回头看 阅读(468) 评论(0) 推荐(0) 编辑
摘要: from typing import Optional, Tuple from fastapi import FastAPI, Request from pydantic import BaseModel # 通过starlette.authentication导入AuthenticationBac 阅读全文 »
posted @ 2024-02-28 18:42 我在路上回头看 阅读(252) 评论(0) 推荐(0) 编辑
摘要: 官网 sqlmodel 安装 # 安装sqlmodel会自动安装pydantic和sqlalchemy pip install sqlmodel 使用 # 步骤1,创建sqlmodel引擎 from sqlmodel import create_engine # driver://用户名:密码@ip 阅读全文 »
posted @ 2024-02-28 18:37 我在路上回头看 阅读(3084) 评论(0) 推荐(0) 编辑
摘要: 应用启动和关闭事件(旧版本) 事件处理程序,在应用程序启动之前和关闭期间执行。每次uvicorn和hypercorn服务器重启加载时都会激活这些事件 app = FastAPI() # 启动事件 @app.on_event("startup") async def initialize(reques 阅读全文 »
posted @ 2024-02-28 18:14 我在路上回头看 阅读(602) 评论(0) 推荐(0) 编辑
摘要: 依赖包 pip install python-dotenv 使用 #.env文件 ADMIN_EMAIL="deadpool@example.com" APP_NAME="ChimichangApp" # config.py from pydantic_settings import BaseSet 阅读全文 »
posted @ 2024-02-28 18:09 我在路上回头看 阅读(315) 评论(0) 推荐(0) 编辑
摘要: 函数式依赖项 from fastapi import FastAPI from fastapi import Query, Depends from fastapi.exceptions import HTTPException app = FastAPI() def username_check( 阅读全文 »
posted @ 2024-02-28 18:07 我在路上回头看 阅读(193) 评论(0) 推荐(0) 编辑
摘要: 注:后台任务应附加到响应中,并且仅在发送响应后运行 用于将单个后台任务添加到响应中 from fastapi import FastAPI from fastapi.responses import JSONResponse from starlette.background import Back 阅读全文 »
posted @ 2024-02-28 17:58 我在路上回头看 阅读(233) 评论(0) 推荐(0) 编辑
点击右上角即可分享
微信分享提示