23 lines
612 B
Python
23 lines
612 B
Python
import requests
|
|
import json
|
|
|
|
def test_prediction_api():
|
|
url = "http://localhost:5000/api/prediction"
|
|
data = {
|
|
"product_id": "P001",
|
|
"model_type": "tcn",
|
|
"future_days": 7
|
|
}
|
|
|
|
try:
|
|
response = requests.post(url, json=data)
|
|
print(f"状态码: {response.status_code}")
|
|
print(f"响应: {response.text}")
|
|
return response.status_code == 200
|
|
except Exception as e:
|
|
print(f"请求失败: {e}")
|
|
return False
|
|
|
|
if __name__ == "__main__":
|
|
success = test_prediction_api()
|
|
print(f"测试{'成功' if success else '失败'}") |