会员
周边
新闻
博问
闪存
赞助商
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
刘宏缔的架构森林
专注架构的博客
博客园
首页
新随笔
联系
订阅
管理
上一页
1
2
3
4
5
6
7
···
201
下一页
2026年7月18日
fastapi:管理后台:用户注册
摘要: 一,要注意的环节: 用户的密码保存时不能用明文,要用bcrypt加密保存 有写库操作,要做try except,发生异常时要做写日志, 有多个参数,要用wtforms做参数的校验 二,代码 python代码: # 得到bcrypt加密后的密码 def get_password_hash(passwo
阅读全文
posted @ 2026-07-18 22:39 刘宏缔的架构森林
阅读(6)
评论(0)
推荐(0)
2026年7月17日
fastapi:模板报错:starlette.routing.NoMatchFound: No route exists for name "static" and params "filename".
摘要: 一,代码和报错信息: 代码: <img class="mb-4 rounded-circle" src="{{ url_for('static', path='image/logo/logo_300.jpg') }}" alt="" width="100"> 报错信息 starlette.routi
阅读全文
posted @ 2026-07-17 19:05 刘宏缔的架构森林
阅读(3)
评论(0)
推荐(0)
flask:从命令行执行自定义命令时报错:Unable to build URLs outside an active request without 'SERVER_NAME' configured. Also configure 'APPLICATION_ROOT' and 'PREFERRED_URL_SCHEME' as needed.
摘要: 一,问题 报错信息: Unable to build URLs outside an active request without 'SERVER_NAME' configured. Also configure 'APPLICATION_ROOT' and 'PREFERRED_URL_SCHEM
阅读全文
posted @ 2026-07-17 14:26 刘宏缔的架构森林
阅读(3)
评论(0)
推荐(0)
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 刘宏缔的架构森林
阅读(5)
评论(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 刘宏缔的架构森林
阅读(28)
评论(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)
上一页
1
2
3
4
5
6
7
···
201
下一页
公告