I'm following the Lab4 from OpenFaas. In the end of this lab you make a programmatic call for another function, but the function start a loop and never finishes:
And int the execution is give me an error:
Here is the pod that should be called:
Someone can help me?
Here is my code
import os
import requests
import sys
def handle(req):
"""handle a request to the function
Args:
req (str): request body
"""
#gateway_hostname = os.getenv("gateway_hostname", "127.0.0.1") # uses a default of "gateway" for when "gateway_hostname" is not set
test_sentence = req
print(test_sentence)
r = requests.get("http://127.0.0.1:8080/function/sentimentanalysis", data= test_sentence)
if r.status_code != 200:
sys.exit("Error with sentimentanalysis, expected: %d, got: %d\n" % (200, r.status_code))
result = r.json()
if result["polarity"] > 0.45:
return "That was probably positive"
else:
return "That was neutral or negative"