configurable BODY when using URL
parent
eb99e9f571
commit
bde26ff2e5
|
|
@ -187,6 +187,7 @@ class Actor(threading.Thread):
|
||||||
self.url = environ["URL"]
|
self.url = environ["URL"]
|
||||||
self.handle = self.handle_url
|
self.handle = self.handle_url
|
||||||
self.headers = [i.split("=")[:2] for i in environ.get("HEADERS", "").split("//") if i]
|
self.headers = [i.split("=")[:2] for i in environ.get("HEADERS", "").split("//") if i]
|
||||||
|
self.body = environ.get("BODY", '{"hotword":"{{hotword}}","context":"{{context}}"}')
|
||||||
log(self.headers)
|
log(self.headers)
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
|
|
@ -219,8 +220,12 @@ class Actor(threading.Thread):
|
||||||
value = value.replace("{{hotword}}", hotword)
|
value = value.replace("{{hotword}}", hotword)
|
||||||
value = value.replace("{{context}}", context)
|
value = value.replace("{{context}}", context)
|
||||||
headers[key] = value
|
headers[key] = value
|
||||||
log("POST", self.url, headers, hotword, context)
|
body = self.body
|
||||||
requests.post(self.url, json={"hotword":hotword, "context":context}, headers=headers)
|
body = body.replace("{{hotword}}", hotword)
|
||||||
|
body = body.replace("{{context}}", context)
|
||||||
|
if environ.get("DEBUG", "") :
|
||||||
|
log("POST", self.url, headers, body)
|
||||||
|
requests.post(self.url, headers=headers, data=body)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
log("Actor.handle_url:", e)
|
log("Actor.handle_url:", e)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue