会员
周边
众包
新闻
博问
闪存
赞助商
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
洗洗睡吧
自闭。。。。。。
博客园
首页
新随笔
联系
订阅
管理
1
2
3
4
5
···
51
下一页
2025年3月3日
inspect反射模块
摘要: 作用 提供获取对象信息的函数,如模块、类、方法、函数、回溯、帧对象和代码对象 类型检查 用于判断对象的类型(如函数,类,生成器等),常用函数 inspcet.isfunction(obj),检查是否为函数 inspect.isclass(obj),检查是否为类 inspect.ismethod(ob
阅读全文
posted @ 2025-03-03 02:21 我在路上回头看
阅读(34)
评论(0)
推荐(0)
2024年2月28日
FastAPI系列:HttpBasic基本认证
摘要: HttpBasic基本认证 from fastapi import FastAPI, Depends from fastapi.security import HTTPBasic, HTTPBasicCredentials from fastapi.exceptions import HTTPExc
阅读全文
posted @ 2024-02-28 19:09 我在路上回头看
阅读(213)
评论(0)
推荐(0)
FastAPI系列:异步redis
摘要: 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 我在路上回头看
阅读(1530)
评论(0)
推荐(0)
FastAPI系列:jwt认证
摘要: jwt认证 1.头部Header,主要是对jwt元数据的描述 { 'alg': 'HS256', 'typ': 'JWT' } 2.载荷playload,主要包含jwt信息需要传递的主体数据 { 'iss': 'jack', # 由jwt签发 'sub': 'jack', # 该jwt面向的用户组,
阅读全文
posted @ 2024-02-28 19:00 我在路上回头看
阅读(508)
评论(0)
推荐(0)
FastAPI系列:自定义认证
摘要: from typing import Optional, Tuple from fastapi import FastAPI, Request from pydantic import BaseModel # 通过starlette.authentication导入AuthenticationBac
阅读全文
posted @ 2024-02-28 18:42 我在路上回头看
阅读(317)
评论(0)
推荐(0)
FastAPI系列:fastapi定制的数据库操作库sqlmodel
摘要: 官网 sqlmodel 安装 # 安装sqlmodel会自动安装pydantic和sqlalchemy pip install sqlmodel 使用 # 步骤1,创建sqlmodel引擎 from sqlmodel import create_engine # driver://用户名:密码@ip
阅读全文
posted @ 2024-02-28 18:37 我在路上回头看
阅读(3895)
评论(0)
推荐(0)
FastAPI系列:应用启动和关闭事件
摘要: 应用启动和关闭事件(旧版本) 事件处理程序,在应用程序启动之前和关闭期间执行。每次uvicorn和hypercorn服务器重启加载时都会激活这些事件 app = FastAPI() # 启动事件 @app.on_event("startup") async def initialize(reques
阅读全文
posted @ 2024-02-28 18:14 我在路上回头看
阅读(748)
评论(0)
推荐(0)
FastAPI系列:环境配置读取
摘要: 依赖包 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 我在路上回头看
阅读(387)
评论(0)
推荐(0)
FastAPI系列:依赖注入
摘要: 函数式依赖项 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 我在路上回头看
阅读(261)
评论(0)
推荐(0)
FastAPI系列:后台任务进程
摘要: 注:后台任务应附加到响应中,并且仅在发送响应后运行 用于将单个后台任务添加到响应中 from fastapi import FastAPI from fastapi.responses import JSONResponse from starlette.background import Back
阅读全文
posted @ 2024-02-28 17:58 我在路上回头看
阅读(262)
评论(0)
推荐(0)
1
2
3
4
5
···
51
下一页
公告