摘要:
一,安装用到的库 在 FastAPI 中,使用 JWT(JSON Web Token)进行身份验证时,现在官方和社区最推荐、使用率最高的组合是: PyJWT:负责生成(Encode)和解析(Decode)JWT 字符串。 passlib[bcrypt]:负责对用户密码进行哈希加盐存储和验证。 Fas 阅读全文
posted @ 2026-06-12 10:53
刘宏缔的架构森林
阅读(11)
评论(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
刘宏缔的架构森林
阅读(5)
评论(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
刘宏缔的架构森林
阅读(5)
评论(0)
推荐(0)
摘要:
一,报错信息: sqlalchemy.exc.StatementError: (builtins.ValueError) Value 123 is not None, True, or False 二,原因: 这个报错的根本原因在于:你把数据库中某个定义为布尔类型(Boolean / BOOL)的字 阅读全文
posted @ 2026-06-12 10:53
刘宏缔的架构森林
阅读(6)
评论(0)
推荐(0)
摘要:
一,报错信息: RuntimeError: 'cryptography' package is required for sha256_password or caching_sha2_password auth methods 原因: 这个错误在 FastAPI(或者更准确地说是底层使用的 PyM 阅读全文
posted @ 2026-06-12 10:53
刘宏缔的架构森林
阅读(11)
评论(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
刘宏缔的架构森林
阅读(12)
评论(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
刘宏缔的架构森林
阅读(4)
评论(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
刘宏缔的架构森林
阅读(2)
评论(0)
推荐(0)
摘要:
一,选择结构 python代码: # app/api/users.py from fastapi import APIRouter, Depends from starlette.requests import Request from starlette.templating import Jin 阅读全文
posted @ 2026-06-12 10:52
刘宏缔的架构森林
阅读(3)
评论(0)
推荐(0)
摘要:
一,安装jinja2模板引擎 $ pip install jinja2 python-multipart 创建模板文件目录templates,并把模板文件放到此目录下 二,代码: html代码: <!DOCTYPE html> <html lang="en"> <head> <meta charse 阅读全文
posted @ 2026-06-12 10:52
刘宏缔的架构森林
阅读(2)
评论(0)
推荐(0)
浙公网安备 33010602011771号