摘要:
一,代码 import hashlib from datetime import datetime, timedelta, timezone from typing import Optional from fastapi import FastAPI, Depends, HTTPException 阅读全文
posted @ 2026-06-12 10:53
刘宏缔的架构森林
阅读(8)
评论(0)
推荐(0)
摘要:
一,安装用到的第三方库 $ pip install redis 说明: redis库和aioredis库两者有什么区别? 这是一个非常经典的“历史遗留”问题。其实在今天,它们已经没有区别了,因为它们已经合并成了同一个库。 简单来说:aioredis 已经被合并到了官方的 redis 库中。 二,代码 阅读全文
posted @ 2026-06-12 10:53
刘宏缔的架构森林
阅读(23)
评论(0)
推荐(0)
摘要:
一,安装用到的库 在 FastAPI 中,使用 JWT(JSON Web Token)进行身份验证时,现在官方和社区最推荐、使用率最高的组合是: PyJWT:负责生成(Encode)和解析(Decode)JWT 字符串。 passlib[bcrypt]:负责对用户密码进行哈希加盐存储和验证。 Fas 阅读全文
posted @ 2026-06-12 10:53
刘宏缔的架构森林
阅读(16)
评论(0)
推荐(0)
摘要:
一,代码: # app/api/products.py import math from fastapi import APIRouter, Request, Depends, HTTPException, Form from pydantic import BaseModel, Field fro 阅读全文
posted @ 2026-06-12 10:53
刘宏缔的架构森林
阅读(6)
评论(0)
推荐(0)
摘要:
一,添加数据 代码: # app/api/products.py from fastapi import APIRouter, Request, Depends, HTTPException, Form from pydantic import BaseModel, Field from app.c 阅读全文
posted @ 2026-06-12 10:53
刘宏缔的架构森林
阅读(8)
评论(0)
推荐(0)
摘要:
一,报错信息: sqlalchemy.exc.StatementError: (builtins.ValueError) Value 123 is not None, True, or False 二,原因: 这个报错的根本原因在于:你把数据库中某个定义为布尔类型(Boolean / BOOL)的字 阅读全文
posted @ 2026-06-12 10:53
刘宏缔的架构森林
阅读(9)
评论(0)
推荐(0)
摘要:
一,报错信息: RuntimeError: 'cryptography' package is required for sha256_password or caching_sha2_password auth methods 原因: 这个错误在 FastAPI(或者更准确地说是底层使用的 PyM 阅读全文
posted @ 2026-06-12 10:53
刘宏缔的架构森林
阅读(15)
评论(0)
推荐(0)
摘要:
一,创建相应的数据库: 二,安装sqlalchemy和mysql驱动 $ pip install sqlalchemy aiomysql pydantic 三,代码 database.py # app/core/database.py from sqlalchemy.orm import sessi 阅读全文
posted @ 2026-06-12 10:53
刘宏缔的架构森林
阅读(24)
评论(0)
推荐(0)
摘要:
一,目录结构 二,代码 main.py # main.py from fastapi import FastAPI from app.api import products, users, account from app.core.exceptions import register_except 阅读全文
posted @ 2026-06-12 10:53
刘宏缔的架构森林
阅读(7)
评论(0)
推荐(0)
摘要:
一,代码: 目录结构: header.html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>{{ title }}</title> </head> <body> <div style="width:100 阅读全文
posted @ 2026-06-12 10:53
刘宏缔的架构森林
阅读(3)
评论(0)
推荐(0)
浙公网安备 33010602011771号