Skip to content

Commit

Permalink
Adding params.
Browse files Browse the repository at this point in the history
  • Loading branch information
jzonthemtn committed Oct 18, 2023
1 parent b830147 commit eed495b
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions philter.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
import requests


def filter(philter_endpoint, text, verify=True):
def filter(philter_endpoint, text, policy="default", verify=True):
headers = {"Content-Type": "text/plain"}
response = requests.post(philter_endpoint + "/api/filter", headers=headers, data=text, verify=verify)
params = {"p": policy}
response = requests.post(philter_endpoint + "/api/filter", params=params, headers=headers, data=text, verify=verify)

if response.status_code == 200:
return response.text
else:
raise Exception("Error response received from Philter.")


def explain(philter_endpoint, text, verify=True):
def explain(philter_endpoint, text, policy="default", verify=True):
headers = {"Content-Type": "text/plain"}
response = requests.post(philter_endpoint + "/api/explain", headers=headers, data=text, verify=verify)
params = {"p": policy}
response = requests.post(philter_endpoint + "/api/explain", params=params, headers=headers, data=text, verify=verify)

if response.status_code == 200:
return response.json()
Expand Down

0 comments on commit eed495b

Please sign in to comment.