File tree Expand file tree Collapse file tree 1 file changed +11
-13
lines changed
comps/guardrails/src/polite_guard Expand file tree Collapse file tree 1 file changed +11
-13
lines changed Original file line number Diff line number Diff line change @@ -56,9 +56,9 @@ Once microservice starts, users can use examples (bash or python) below to apply
5656** Bash:**
5757
5858``` bash
59- curl localhost:9092/v1/polite
60- -X POST
61- -d ' {"text":"He is stupid"}'
59+ curl localhost:9092/v1/polite \
60+ -X POST \
61+ -d ' {"text":"He is stupid"}' \
6262 -H ' Content-Type: application/json'
6363```
6464
@@ -72,18 +72,16 @@ Example Output:
7272
7373``` python
7474import requests
75- import json
7675
77- proxies = { " http " : " " }
76+ # Define the URL and payload
7877url = " http://localhost:9092/v1/polite"
79- data = {" text" : " He is stupid" }
78+ payload = {" text" : " He is stupid" }
79+ headers = {" Content-Type" : " application/json" }
8080
81+ # Send a POST request
82+ response = requests.post(url, json = payload, headers = headers)
8183
82- try :
83- resp = requests.post(url = url, data = data, proxies = proxies)
84- print (resp.text)
85- resp.raise_for_status() # Raise an exception for unsuccessful HTTP status codes
86- print (" Request successful!" )
87- except requests.exceptions.RequestException as e:
88- print (" An error occurred:" , e)
84+ # Print the response
85+ print (" Status Code:" , response.status_code)
86+ print (" Response Body:" , response.json())
8987```
You can’t perform that action at this time.
0 commit comments