wgz_forecast/wgz_forecast(lh)/test.py

21 lines
622 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.

import requests
import pandas as pd
import numpy as np
# 这里使用的是load进行预测可改(load/pv/water/carbon)
url = "http://127.0.0.1:2467/load"
data = {
"inputs":(np.random.randn(24)*100).tolist()
}
response = requests.post(url, json=data)
print("Status Code:", response.status_code) # 打印状态码
print("Response Content:", response.text) # 打印响应内容
if response.status_code == 200:
try:
print(response.json()) # 尝试解析 JSON
except requests.exceptions.JSONDecodeError as e:
print("JSON Decode Error:", e)
else:
print("Error:", response.status_code)