-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmulti_task.py
More file actions
40 lines (24 loc) · 797 Bytes
/
multi_task.py
File metadata and controls
40 lines (24 loc) · 797 Bytes
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import json
import requests
import signal
import sys
def handle_sigint(sig, frame):
print('\n\nThank you for using the application.\nClosing now...')
sys.exit(0)
URL = 'http://localhost:7150/parse'
headers = {
'Content-Type': 'application/json',
}
signal.signal(signal.SIGINT, handle_sigint)
payload = '{"text": "Hi"}'
response = requests.post(url=URL, headers=headers, data=payload)
data = response.json()
reply = data['directives'][0]['payload']['text']
print('App: ' + reply)
while True:
inp = input('You: ')
payload = '{"text":"%s", "frame":%s}' % (inp, json.dumps(data['frame']))
response = requests.post(url=URL, headers=headers, data=payload)
data = response.json()
reply = data['directives'][0]['payload']['text']
print('App: ' + reply)