Curd
restful api server template(FastAPI)
Install / Use
/learn @nanarino/CurdREADME
☘ 簡易接口模板
自用但不推薦使用的 簡易的 FastAPI DEMO 模板。
接口頻率限制依賴 redis,自用不需要時可以卸掉這個功能
初始運轉
記得先進入虛擬環境(或使用 uv run)
# 安裝依賴
pip install -r requirements.txt
## 或者使用uv
uv sync
### 在這之前可以使全部套件更到最新 若出問題了直接issue
# uv lock --upgrade
# 配置好./config.ini后創建空白資料表
# PS: $env:PYTHONPATH = "./"
# SH: export PYTHONPATH=./
python ./scripts/db_create.py
## 或者使用uv
uv run ./scripts/db_create.py
# 運轉項目
python app.py
## 或者使用uv
uv run app.py
API demo
增刪改查完備,啓動后見 swagger 文档
- GET /demo/{id} 指定獲取單條
- PUT /demo/{id} 修改指定單條
- POST /demo 新增單條
- GET /demos 分頁獲取多條
- DELETE /demos 刪除指定多條
目錄結構
/nanarino/curd # cwd
│
├── app.py # 程式入口
├── config.ini # 配置文件
├── api
│ ├── __init__.py
│ ├── auth.py # Oauth2授權 登錄注冊的api
│ ├── schemas.py # 類型檢查以及DTO
│ └── demo.py # 一組增刪改查的 DEMO api
├── db
│ ├── __init__.py
│ ├── base.py # 資料物件基類
│ └── models.py # 資料庫模型
├── util # 工具函式
└── requirements.txt # 依賴的pip包
# 後面使用 `uv add -r requirements.txt` 補上了uv配置
│
static/index.html # 爲 DEMO api 編撰的 增删改查DEMO界面
示例界面
運行後訪問: http://127.0.0.1:8080/
UI 組件: UI5 Web Components
組件依賴使用 JSPM 工具 从 cdn 獲取 importmap,所以無需 nodejs 環境
Related Skills
feishu-drive
344.1k|
things-mac
344.1kManage Things 3 via the `things` CLI on macOS (add/update projects+todos via URL scheme; read/search/list from the local Things database)
clawhub
344.1kUse the ClawHub CLI to search, install, update, and publish agent skills from clawhub.com
postkit
PostgreSQL-native identity, configuration, metering, and job queues. SQL functions that work with any language or driver
