Skip to main content

示例 Python 项目,通过 logging 输出简单信息。

Project description

Python 示例项目

本项目使用 setuptoolspyproject.toml 管理依赖,示范如何构建可执行的命令行工具。

快速开始

  1. 进入项目目录
    cd python_app
    
  2. 创建虚拟环境
    python3 -m venv .venv
    source .venv/bin/activate
    
  3. 安装依赖
    pip install -e .[dev]
    
  4. 运行主程序
    python-app-demo --name 世界
    
  5. 运行测试
    pytest
    

项目结构

├── pyproject.toml
├── README.md
├── src
│   └── app
│       ├── __init__.py
│       └── main.py
└── tests
    ├── __init__.py
    └── test_main.py

日志

主程序使用标准库 logging 记录调试与信息级别的日志,并在处理用户输入时输出详细信息,方便排查问题。

MCP 服务

命令行新增 --mode mcp 参数,可启动基于 FastMCP 的服务,当前暴露以下工具:

  • generate_greeting:生成问候语,复用 CLI 逻辑。
  • get_current_time:返回当前时间与时间戳。

示例:

python -m app.main --mode mcp

如需在 MCP 模式下使用 Teable 相关工具,可通过命令行参数传入配置(优先级高于环境变量):

python -m app.main --mode mcp \
  --teable-base-url https://app.teable.cn \
  --teable-token "teable_xxx" \
  --teable-base-id bseXXXXXXXXXXXX
Requires:
- Python >= 3.10

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

python_app_demo-1.7.0.tar.gz (12.3 kB view details)

Uploaded Source

Built Distribution

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

python_app_demo-1.7.0-py3-none-any.whl (12.3 kB view details)

Uploaded Python 3

File details

Details for the file python_app_demo-1.7.0.tar.gz.

File metadata

  • Download URL: python_app_demo-1.7.0.tar.gz
  • Upload date:
  • Size: 12.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for python_app_demo-1.7.0.tar.gz
Algorithm Hash digest
SHA256 43298c32ed6001d83920344e8ed17b6bc7c46f5460b4c8f16f35744a0ad8b369
MD5 c0b2d2c28f85e916b7a25d6a209efc60
BLAKE2b-256 2fa55a84f29dab7f40bd3f7acca24ad40ec699462111cccdeb6618aed398b399

See more details on using hashes here.

File details

Details for the file python_app_demo-1.7.0-py3-none-any.whl.

File metadata

File hashes

Hashes for python_app_demo-1.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4d523e1a7be9c1e8c43a9313ad3cb2df9025c81c00eeb9427260d6a2c496a3aa
MD5 8fb792eb62cae240acd91c224280f1f5
BLAKE2b-256 50b262c831ffd346d3a3c7c653480c02f8b0c5c53b85232c356beb910c7ef1e0

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