"""一次性脚本：测试后端登录 API，获取 JWT token"""
import requests
import json
import sys

url = "http://127.0.0.1:8000/api/auth/login"
payload = {"username": "admin", "password": "admin123"}

try:
    resp = requests.post(url, json=payload, timeout=10)
    print(f"Status: {resp.status_code}")
    print(f"Body: {json.dumps(resp.json(), indent=2, ensure_ascii=False)}")
except Exception as e:
    print(f"Error: {e}", file=sys.stderr)
    sys.exit(1)
