Files
Neo-ZQYY/scripts/ops/_login_test.py

16 lines
467 B
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""一次性脚本:测试后端登录 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)