import requests import json # 测试创建产品API def test_create_product(): url = "http://localhost:5000/api/v1/products" headers = {"Content-Type": "application/json"} data = { "product_name": "测试产品", "description": "这是一个测试产品" } try: response = requests.post(url, headers=headers, data=json.dumps(data)) print(f"Status Code: {response.status_code}") print(f"Response: {response.text}") except Exception as e: print(f"Error: {e}") if __name__ == "__main__": test_create_product()