会员
周边
新闻
博问
闪存
众包
赞助商
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
waketzheng
博客园
首页
新随笔
联系
订阅
管理
2025年12月22日
fastapi全局响应格式
摘要: 商女不知亡国恨 却道天凉好个秋 首先声明,个人建议,不要有什么code、message,直接返回data给前端就好,status_code小于300就是成功,大于等于400就是失败。 但有些项目,确实不方便有200以外的status_code或是需要统一响应字段为code/message/data
阅读全文
posted @ 2025-12-22 13:03 waketzheng
阅读(5)
评论(0)
推荐(0)
2025年11月22日
A script to set mysql gtid-mode off by tortoise-orm
摘要: 醉来不知天在水 满船清梦压星河 MySQL9.0+之后,gtid_mode无法直接从ON改为OFF,需要先经过ON_PERMISSIVE和OFF_PERMISSIVE 该脚本使用tortoise-orm==0.25.1读取环境变量TORTOISE_MYSQL_PASS作为数据库密码,然后关闭enfo
阅读全文
posted @ 2025-11-22 22:32 waketzheng
阅读(7)
评论(0)
推荐(0)
FastAPI docker demo
摘要: 何当共剪西窗烛 却话巴山夜雨时 使用Docker来启动fastapi项目: # 第一阶段:安装必要的软件 FROM python:3.12-slim as BASE ENV DEBIAN_FRONTEND=noninteractive \ PYTHONUNBUFFERED=1 \ PIP_DEFAU
阅读全文
posted @ 2025-11-22 17:27 waketzheng
阅读(17)
评论(0)
推荐(0)
2025年11月19日
腾讯云ubuntu服务器初始化
摘要: 巴山楚水凄凉地 二十四桥明月夜 查看apt速度,如果慢的话,手动给它换源 sudo apt update 更新系统软件包,过程中有需要选择的,直接回车就行 sudo apt upgrade -y && sudo apt autoremove -y # 升级ubuntu版本,如:ubuntu22.04
阅读全文
posted @ 2025-11-19 23:45 waketzheng
阅读(7)
评论(0)
推荐(0)
2025年8月20日
Use python to proxy http by sanic
摘要: 但使龙城飞将在 不教胡马渡阴山 Code: #!/usr/bin/env python import re # pip install httpx orjson loguru sanic gunicorn 'uvicorn[standard]' from httpx import AsyncClie
阅读全文
posted @ 2025-08-20 18:03 waketzheng
阅读(7)
评论(0)
推荐(0)
2025年8月15日
Prepare python tools: uv/pdm/...
摘要: 齐鲁青未了 造化钟神秀 阴阳割昏晓 Set mirror for pip mkdir ~/archives cd ~/archives git clone https://github.com/waketzheng/carstino cd carstino python pip_conf.py --
阅读全文
posted @ 2025-08-15 15:59 waketzheng
阅读(29)
评论(0)
推荐(0)
2025年8月10日
Python 标准库 HTTP Client 封装 (带 Headers 的 JSON 请求)
摘要: 岱宗夫如何 千山鸟飞绝 万径人踪灭 问了DeepSeek,然后优化了一下,适用于不方便安装requests和httpx的情况: from typing import Any, Self from urllib.error import HTTPError, URLError from urllib.
阅读全文
posted @ 2025-08-10 20:13 waketzheng
阅读(25)
评论(0)
推荐(0)
2025年8月8日
Use python tkinter to get user input from text area
摘要: 问渠哪得清如许 白云深处有人家 cat gui.py from __future__ import annotations import sys import tkinter as tk class TkGui: @classmethod def input(cls, prompt: str = "
阅读全文
posted @ 2025-08-08 23:17 waketzheng
阅读(14)
评论(0)
推荐(0)
2025年8月7日
python typer show cli version
摘要: 但愿人长久 千里共婵娟 $ cat main.py from __future__ import annotations import re from pathlib import Path import typer __version__ = "0.1.2" cli = typer.Typer()
阅读全文
posted @ 2025-08-07 10:43 waketzheng
阅读(10)
评论(0)
推荐(0)
2025年8月4日
It's yesterday once more
摘要: 江山如此多娇 玉人何处教吹箫 Updated At 2025-11-30 Would rather to use justfile instead: #!/usr/bin/env -S just --justfile # ^ A shebang isn't required, but allows
阅读全文
posted @ 2025-08-04 22:59 waketzheng
阅读(10)
评论(0)
推荐(0)
下一页
公告