-
Notifications
You must be signed in to change notification settings - Fork 1
/
API_TEST.py
25 lines (21 loc) · 862 Bytes
/
API_TEST.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import requests
#url = 'http://localhost:5000/generate_response'
#url = 'http://127.0.0.1:5000/generate_response'
#url = 'http://172.28.0.12:5000/generate_response'
url = 'https://475f-35-233-241-28.ngrok-free.app/generate_response'
data = {'user_send_input': "your opinion pleae"}
response = requests.post(url, json=data)
print("Request Status Code:", response.status_code)
print("Response Text:", response.text)
try:
if response.status_code == 200:
response_json = response.json()
if 'response' in response_json:
response_text = response_json['response']
print("Generated Response:", response_text)
else:
print("Response JSON doesn't contain 'response' key:", response_json)
else:
print("Error Response")
except Exception as e:
print("Exception during response handling:", e)