Skip to main content

NoticeCard server with RESTful API and web UI

Project description

NoticeCard Server

一个基于 FastAPI 的卡片管理系统,提供完整的 RESTful API 和现代化的 Web UI 界面。

特性

  • ✨ 基于 FastAPI 的高性能 RESTful API
  • 📝 完整的 CRUD 操作支持
  • 🎨 集成 Tabler UI 的响应式前端界面
  • 📱 自适应布局,支持手机、平板和桌面设备
  • 📚 自动生成的 OpenAPI/Swagger 文档
  • 💾 SQLite 数据库,轻量级无需额外配置
  • 🛠️ 命令行工具,简化部署和管理
  • 🔄 CORS 支持,便于前后端分离开发
  • 📄 分页支持,高效处理大量数据
  • 🚨 完善的错误处理和事务回滚
  • ⚡ 开发模式支持热重载

安装

从 PyPI 安装(发布后)

pip install noticecard

本地开发安装

# 克隆仓库
git clone https://gitee.com/candy_xt/noticecard-server.git
cd noticecard-server

# 安装依赖
pip install -e .

快速开始

启动服务器

# 使用默认配置启动(0.0.0.0:3143)
ncard serve

# 指定主机和端口
ncard serve --host 127.0.0.1 --port 8080

# 指定工作目录(数据库存储位置)
ncard serve --dir ./my_data

# 开发模式(自动重载)
ncard serve --reload

# 指定日志级别
ncard serve --log-level debug

# 组合使用
ncard serve --host 0.0.0.0 --port 8080 --dir ./data --reload --log-level info

访问服务

API 端点

卡片管理

  • GET /cards/ - 获取所有卡片(支持分页)
    • 查询参数:skip(跳过数量,默认0)、limit(限制数量,默认100)
  • GET /cards/{card_id} - 获取指定卡片
  • POST /cards/ - 创建新卡片
  • PUT /cards/{card_id} - 更新卡片
  • DELETE /cards/{card_id} - 删除卡片

请求示例

创建卡片:

curl -X POST "http://localhost:3143/cards/" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "会议通知",
    "description": "明天下午2点在一号会议室"
  }'

获取所有卡片:

curl "http://localhost:3143/cards/"

# 使用分页
curl "http://localhost:3143/cards/?skip=0&limit=10"

数据模型

Card

字段 类型 说明
id Integer 主键,自动生成
title String 标题(必填)
description String 描述(可选)
created_at DateTime 创建时间
updated_at DateTime 更新时间

CLI 命令

serve

启动 NoticeCard 服务器。

ncard serve [OPTIONS]

选项:

  • --host TEXT - 绑定的主机地址(默认:0.0.0.0)
  • --port INTEGER - 绑定的端口(默认:3143)
  • --dir TEXT - 工作目录,用于存储数据库(默认:当前目录)
  • --reload - 启用自动重载(开发模式)
  • --log-level - 日志级别:critical, error, warning, info, debug(默认:info)

init

初始化数据库。

ncard init [OPTIONS]

选项:

  • --dir TEXT - 工作目录(默认:当前目录)

开发

项目结构

noticecard/
├── noticecard/
│   ├── __init__.py
│   ├── app.py          # FastAPI 应用
│   ├── models.py       # 数据库模型
│   ├── schemas.py      # Pydantic 模型
│   ├── templates.py    # HTML 模板
│   └── cli.py          # CLI 工具
├── pyproject.toml      # 项目配置
├── README.md
└── .gitignore

运行测试

pip install -e ".[dev]"
pytest

构建发布包

pip install build twine
python -m build
twine upload dist/*

技术栈

  • FastAPI - 现代化的 Python Web 框架
  • SQLAlchemy - SQL 工具包和 ORM
  • Pydantic - 数据验证和设置管理
  • Click - 命令行工具框架
  • Uvicorn - ASGI 服务器
  • Tabler UI - 响应式前端框架

贡献

欢迎提交 Issue 和 Pull Request!

仓库地址:https://gitee.com/candy_xt/noticecard-server

许可证

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

noticecard-0.2.1.tar.gz (16.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

noticecard-0.2.1-py3-none-any.whl (15.9 kB view details)

Uploaded Python 3

File details

Details for the file noticecard-0.2.1.tar.gz.

File metadata

  • Download URL: noticecard-0.2.1.tar.gz
  • Upload date:
  • Size: 16.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for noticecard-0.2.1.tar.gz
Algorithm Hash digest
SHA256 bd27df1b34744cdc95a106e87980a92ad05cca71766bb45b15979ea4e1898f25
MD5 a85d9ffebbcf332ddabdbb287059f140
BLAKE2b-256 7dad545d730a4d470eb7b92ec7620da724b1291dc2f95e820bab322a8650ca23

See more details on using hashes here.

File details

Details for the file noticecard-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: noticecard-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 15.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for noticecard-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 31bd110f1e49e2ba2bbd7adab4986a1a12804ef55fbaf3e064d347124ce3de41
MD5 645106df3ae0c7d5bd87931c65d1f1a7
BLAKE2b-256 bf8eaeb939319fee56c933839a2c5f3f603b480db3797f71699fd04c881faf25

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page