会员
周边
新闻
博问
闪存
赞助商
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
刘宏缔的架构森林
专注架构的博客
博客园
首页
新随笔
联系
订阅
管理
上一页
1
2
3
4
5
6
···
200
下一页
2026年7月14日
es: 临时指定一部分doc的排序靠前
摘要: 一,代码 # es分页搜索,通过关健词列表 def es_topic_search_by_list(qk_list): should_list = [] for qk in qk_list: qk_one = qk.strip() if qk_one == '': continue one_q1 =
阅读全文
posted @ 2026-07-14 21:52 刘宏缔的架构森林
阅读(4)
评论(0)
推荐(0)
2026年7月12日
fastapi: jinja2:模板继承
摘要: 一,代码: base.html <!-- base.html --> <!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="UTF-8"> <!-- 预留标题块,并可以设置默认值 --> <title>{% block title %}我
阅读全文
posted @ 2026-07-12 23:16 刘宏缔的架构森林
阅读(4)
评论(0)
推荐(0)
fastapi:jinja2: 用WTForms 在 Jinja2 里快速生成 HTML 标签
摘要: 一,安装第三方库: $ pip install WTForms 二,代码 python: # app/api/users.py from fastapi import APIRouter, Depends from starlette.requests import Request from sta
阅读全文
posted @ 2026-07-12 23:16 刘宏缔的架构森林
阅读(4)
评论(0)
推荐(0)
ai相关:三大AI编程工具,OpenCode、OpenAI Codex 与 Claude Code,你选哪个?
摘要: OpenCode、OpenAI Codex 与 Claude Code 是目前主流的三大终端级(CLI/Agent)AI 编程工具。它们都支持直接在你的本地终端和代码库中运行,通过自然语言自动修改文件、运行测试、甚至自主定位 Bug。但在开源程度、核心逻辑、以及具体的适用场景上,三者存在明显的区别。
阅读全文
posted @ 2026-07-12 23:16 刘宏缔的架构森林
阅读(23)
评论(0)
推荐(0)
2026年6月29日
fastapi: 如何指定用户登录的强依赖和弱依赖?
摘要: 一,代码 jwt功能模块和用户登录的两个依赖项: import hashlib from datetime import datetime, timedelta, timezone from typing import Optional from fastapi import FastAPI, De
阅读全文
posted @ 2026-06-29 20:09 刘宏缔的架构森林
阅读(2)
评论(0)
推荐(0)
fastapi: 用starlette-context保存request对象,使不需要专递参数也可以从各处访问request
摘要: 一,代码: plugin: from starlette.requests import Request from starlette_context.plugins import Plugin class PythonRequestPlugin(Plugin): # 1. 定义在 context
阅读全文
posted @ 2026-06-29 20:09 刘宏缔的架构森林
阅读(7)
评论(0)
推荐(0)
fastapi:用starlette-context实现存储当前登录用户,后续的任何业务代码直接读取,无需通过依赖注入传递
摘要: 一,安装第三方库 库地址: https://pypi.org/project/starlette-context/ 安装: $ pip install starlette-context 二,代码 1,登录后把用户信息保存到上下文中 from starlette_context.plugins im
阅读全文
posted @ 2026-06-29 20:09 刘宏缔的架构森林
阅读(8)
评论(0)
推荐(0)
fastapi:给管理后台增加http basic登录验证
摘要: 一,代码 说明:只针对admin管理后台,不影响其他子应用如api basic的代码 # app/core/adminbasic.py import secrets from fastapi import FastAPI, Depends, HTTPException, status from fa
阅读全文
posted @ 2026-06-29 20:09 刘宏缔的架构森林
阅读(6)
评论(0)
推荐(0)
2026年6月25日
fastapi:fastapi项目的线上部署,gunicorn和supervisor分别起了什么作用?
摘要: 在生产环境中,不建议直接运行 uvicorn main:app,因为一旦程序崩溃不会自动重启,且无法利用多核 CPU。所以我们使用 Gunicorn 来管理 Uvicorn。 在 FastAPI 项目的线上部署中,Gunicorn 和 Supervisor 扮演着完全不同的角色,它们的分工极其明确。
阅读全文
posted @ 2026-06-25 23:12 刘宏缔的架构森林
阅读(20)
评论(0)
推荐(0)
fastapi: 用alembic实现数据库迁移
摘要: 一,安装用到的第三方库,并初始化 $ pip install alembic 初始化,注意指定异步模板: alembic init -t async alembic 因为我们使用的是异步驱动(aiomysql),初始化时必须指定 async 异步模板:执行后,项目根目录下会多出 alembic.in
阅读全文
posted @ 2026-06-25 16:28 刘宏缔的架构森林
阅读(9)
评论(0)
推荐(0)
上一页
1
2
3
4
5
6
···
200
下一页
公告