EasyScan Server - A FastAPI-based server for EasyScan
Project description
EasyScan Server
一个基于FastAPI的URL短链接服务,支持实时二维码生成和Server-Sent Events (SSE) 推送更新。
🚀 功能特性
- URL短链接服务: 生成短链接并支持重定向
- 实时二维码: 动态生成二维码,支持实时更新
- Server-Sent Events: 实时推送URL和名称变更
- Redis存储: 支持Redis和FakeRedis(开发/测试)
- RESTful API: 完整的REST API接口
- Docker支持: 容器化部署
- 可选名称: 为URL添加自定义名称
📦 安装
使用 pip 安装
pip install easyscan-server
从源码安装
git clone https://github.com/your-username/easyscan-server.git
cd easyscan-server
pip install -e .
🏃 快速开始
启动服务器
# 使用默认配置启动
python -m easyscan_server
# 自定义主机和端口
python -m easyscan_server --host 0.0.0.0 --port 8080
使用Docker
# 构建镜像
docker build -t easyscan-server .
# 运行容器
docker run -p 8000:8000 easyscan-server
🔧 配置
环境变量
USE_REAL_REDIS: 设置此变量以使用真实的Redis(否则使用FakeRedis)REDIS_URL: Redis连接URL(默认:redis://localhost:6379)
示例配置
# 使用真实Redis
export USE_REAL_REDIS=1
export REDIS_URL=redis://localhost:6379
# 启动服务
python -m easyscan_server
📚 API 文档
创建短链接
POST /
Content-Type: application/json
{
"url": "https://example.com",
"name": "示例网站"
}
响应:
{
"key": "abc123def456",
"url": "https://example.com",
"name": "示例网站",
"success": true
}
获取URL信息
GET /{key}
响应:
{
"key": "abc123def456",
"url": "https://example.com",
"name": "示例网站"
}
更新现有链接
POST /{key}
Content-Type: application/json
{
"url": "https://newexample.com",
"name": "新示例网站"
}
重定向到目标URL
GET /{key}/redirect
查看二维码页面
GET /{key}/qrcode
Server-Sent Events
GET /sse/{key}
🏗️ 项目结构
easyscan-server/
├── __init__.py
├── __main__.py # 程序入口点
├── main.py # FastAPI应用主文件
├── domain.py # 数据层和业务逻辑
├── type.py # Pydantic模型定义
└── templates/
└── qrcode.html # 二维码页面模板
🧪 开发
设置开发环境
# 克隆仓库
git clone https://github.com/your-username/easyscan-server.git
cd easyscan-server
# 安装依赖
pip install -e .
# 运行开发服务器
python -m easyscan_server --host 0.0.0.0 --port 8000
依赖项
- FastAPI: Web框架
- Uvicorn: ASGI服务器
- Redis: 数据存储
- FakeRedis: 测试用Redis模拟器
- Pydantic: 数据验证
- Jinja2: 模板引擎
- Typer: CLI工具
🐳 Docker 部署
基本部署
docker run -p 8000:8000 easyscan-server
使用真实Redis部署
# 启动Redis容器
docker run -d --name redis redis:alpine
# 启动EasyScan Server并连接Redis
docker run -p 8000:8000 \
-e USE_REAL_REDIS=1 \
-e REDIS_URL=redis://redis:6379 \
--link redis:redis \
easyscan-server
Docker Compose
version: '3.8'
services:
redis:
image: redis:alpine
ports:
- "6379:6379"
easyscan-server:
image: easyscan-server
ports:
- "8000:8000"
environment:
- USE_REAL_REDIS=1
- REDIS_URL=redis://redis:6379
depends_on:
- redis
📝 许可证
本项目采用 GNU Affero General Public License v3.0 许可证。详见 LICENSE 文件。
🤝 贡献
欢迎贡献!请阅读我们的贡献指南并提交Pull Request。
📞 支持
如果您遇到问题或有功能建议,请创建一个 Issue。
🙏 鸣谢
感谢以下开源项目和技术为EasyScan Server提供支持:
核心技术
开发工具
前端技术
- QRCode.js - JavaScript二维码生成库
- Server-Sent Events - 实时数据推送技术
部署和打包
- Docker - 容器化平台
- uv - 现代Python包管理器
- GitHub Actions - CI/CD自动化
特别感谢所有开源社区的贡献者们,是你们让这个项目成为可能! 🚀
EasyScan Server - 让URL分享变得简单快捷! 🚀
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file easyscan_server-0.1.2.tar.gz.
File metadata
- Download URL: easyscan_server-0.1.2.tar.gz
- Upload date:
- Size: 19.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f380332eac9f7f3358e8f32a0365176567ddd346c2100e85b256eef0107b6da3
|
|
| MD5 |
f50a701397c804c16e3bc839f0c104e5
|
|
| BLAKE2b-256 |
02453376287ac37dd6e78849f8d9b85f8b90f14a9d81c4117ac1efe146e11976
|
Provenance
The following attestation bundles were made for easyscan_server-0.1.2.tar.gz:
Publisher:
publish.yml on LiYulin-s/easyscan-server
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
easyscan_server-0.1.2.tar.gz -
Subject digest:
f380332eac9f7f3358e8f32a0365176567ddd346c2100e85b256eef0107b6da3 - Sigstore transparency entry: 253346356
- Sigstore integration time:
-
Permalink:
LiYulin-s/easyscan-server@8f686de181a0492c5648958b43c260c124bde97a -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/LiYulin-s
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@8f686de181a0492c5648958b43c260c124bde97a -
Trigger Event:
push
-
Statement type:
File details
Details for the file easyscan_server-0.1.2-py3-none-any.whl.
File metadata
- Download URL: easyscan_server-0.1.2-py3-none-any.whl
- Upload date:
- Size: 20.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7c9e01fe48b2db2bc37216dac02f1a32b1797fcb9c9ffc20992edff6b7bb47ee
|
|
| MD5 |
eeca2eda8e47384ec668230dd108975d
|
|
| BLAKE2b-256 |
df565ace0fc3d3f74e8dc126281b4fdedf6e732727a6f55e15fb663762c62682
|
Provenance
The following attestation bundles were made for easyscan_server-0.1.2-py3-none-any.whl:
Publisher:
publish.yml on LiYulin-s/easyscan-server
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
easyscan_server-0.1.2-py3-none-any.whl -
Subject digest:
7c9e01fe48b2db2bc37216dac02f1a32b1797fcb9c9ffc20992edff6b7bb47ee - Sigstore transparency entry: 253346359
- Sigstore integration time:
-
Permalink:
LiYulin-s/easyscan-server@8f686de181a0492c5648958b43c260c124bde97a -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/LiYulin-s
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@8f686de181a0492c5648958b43c260c124bde97a -
Trigger Event:
push
-
Statement type: