Inventree Python API:使用 YAML 配置的最小 API 连接示例

此示例允许你创建配置文件 inventree.yml

inventree.yml
server: 'https://inventree.mydomain.com'
username: 'admin'
password: 'Chuiquu5Oqu8il5ahLoja4aecai4ee'

然后在 Python 中读取它并连接到 Inventree API:

inventree_connect.py
from inventree.api import InvenTreeAPI

# 加载配置
import yaml

with open("inventree.yml", "r") as file:
    config = yaml.safe_load(file)

api = InvenTreeAPI(config["server"], username=config["username"], password=config["password"])

Check out similar posts by category: InvenTree, Python