# client_printer **Repository Path**: lipeng260/client_printer ## Basic Information - **Project Name**: client_printer - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-10-31 - **Last Updated**: 2026-01-12 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ### 发布流程 1. 修改version.py版本 2. 打包(请在目标平台上打包,PyInstaller 不支持跨平台构建): - Windows: `pyinstaller --onefile --name client_printer --add-data "version.m3u;." --add-data "ssl;ssl" --add-binary "wkhtmltopdf.exe;." --add-binary "SumatraPDF-3.5.2-32.exe;." --windowed main.py` - macOS/Linux(分隔符为冒号:;注意这两款 .exe 仅在 Windows 上可运行): `pyinstaller --onefile --name client_printer --add-data "version.m3u:." --add-data "ssl;ssl" --add-binary "wkhtmltopdf.exe:." --add-binary "SumatraPDF-3.5.2-32.exe:." --windowed main.py` 3. 压缩到zip, 命名为client_printer_v{version}.zip 3. 发布到gitee ### 运行与接口 - 打印服务使用 Python 内置 `http.server`,默认监听 `9001` 端口。 - 版本信息服务使用 `http.server`,可通过 `--listen_port` 指定端口。 跨域(CORS): - 已为两个服务开启 CORS,允许跨域访问。 - 允许方法:`GET, POST, OPTIONS` - 允许请求头:`Content-Type, Authorization` - 允许来源:`*` 示例: - 启动:`python main.py --listen_port 8080` - 健康探针:`curl http://localhost:9001/` 返回 `打印服务` - 打印接口: - `POST http://localhost:9001/print` - Body(JSON):`{"html":"

hello

","paper_size":"A4","paper_orientation":"portrait","paper_margin_mm":10}` 运行说明: - 程序在打包后会通过 `version.resource_path` 自动定位 `wkhtmltopdf.exe` 与 `SumatraPDF-3.5.2-32.exe`,无需手动拷贝。 - 仅在 Windows 平台调用上述两款可执行文件;非 Windows 平台将改用系统 `lp/lpr` 打印。