Spaces:
Running
Running
Commit
·
34cbe39
1
Parent(s):
83ebe3c
move to env vars
Browse files
app.py
CHANGED
@@ -7,24 +7,28 @@ from requests import Session
|
|
7 |
import urllib.parse
|
8 |
|
9 |
|
|
|
|
|
|
|
|
|
10 |
class Client:
|
11 |
def __init__(self):
|
12 |
self.c = Session()
|
13 |
self.c.headers.update({
|
14 |
'Content-Type': 'application/json',
|
15 |
-
'Authorization': 'Bearer
|
16 |
})
|
17 |
|
18 |
def send_message(self, input):
|
19 |
res = self.c.post(
|
20 |
-
|
21 |
json={'message': {'text': input}}
|
22 |
)
|
23 |
return res.json()
|
24 |
|
25 |
def send_images(self, images, text):
|
26 |
res = self.c.post(
|
27 |
-
|
28 |
files={'incoming_files': images, 'text': text}
|
29 |
)
|
30 |
return res.json()
|
|
|
7 |
import urllib.parse
|
8 |
|
9 |
|
10 |
+
API_URL = os.environ.get('API_URL')
|
11 |
+
API_TOKEN = os.environ.get('API_TOKEN')
|
12 |
+
|
13 |
+
|
14 |
class Client:
|
15 |
def __init__(self):
|
16 |
self.c = Session()
|
17 |
self.c.headers.update({
|
18 |
'Content-Type': 'application/json',
|
19 |
+
'Authorization': f'Bearer {API_TOKEN}'
|
20 |
})
|
21 |
|
22 |
def send_message(self, input):
|
23 |
res = self.c.post(
|
24 |
+
API_URL,
|
25 |
json={'message': {'text': input}}
|
26 |
)
|
27 |
return res.json()
|
28 |
|
29 |
def send_images(self, images, text):
|
30 |
res = self.c.post(
|
31 |
+
API_URL,
|
32 |
files={'incoming_files': images, 'text': text}
|
33 |
)
|
34 |
return res.json()
|