Spaces:
Sleeping
Sleeping
Commit ·
96aaa55
1
Parent(s): ddcaf67
Update app/functions.py
Browse files- app/functions.py +8 -6
app/functions.py
CHANGED
|
@@ -2,13 +2,15 @@ import os, json
|
|
| 2 |
import requests
|
| 3 |
|
| 4 |
API_ENDPOINT = os.environ.get("API_ENDPOINT")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
def handle_url(url, from_lang, to_lang, gender):
|
| 7 |
-
headers = {
|
| 8 |
-
'accept': 'application/json',
|
| 9 |
-
'Content-Type': 'application/json',
|
| 10 |
-
}
|
| 11 |
-
|
| 12 |
data = {
|
| 13 |
'url': url,
|
| 14 |
'from_lang': from_lang,
|
|
@@ -20,7 +22,7 @@ def handle_url(url, from_lang, to_lang, gender):
|
|
| 20 |
return response.json()
|
| 21 |
|
| 22 |
def get_health():
|
| 23 |
-
response = requests.get(API_ENDPOINT)
|
| 24 |
print(response)
|
| 25 |
print(response.json())
|
| 26 |
return "TRUE"
|
|
|
|
| 2 |
import requests
|
| 3 |
|
| 4 |
API_ENDPOINT = os.environ.get("API_ENDPOINT")
|
| 5 |
+
TOKEN = os.environ.get("TOKEN")
|
| 6 |
+
|
| 7 |
+
headers = {
|
| 8 |
+
'accept': 'application/json',
|
| 9 |
+
'Content-Type': 'application/json',
|
| 10 |
+
'Authorization': f'Bearer {TOKEN}'
|
| 11 |
+
}
|
| 12 |
|
| 13 |
def handle_url(url, from_lang, to_lang, gender):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
data = {
|
| 15 |
'url': url,
|
| 16 |
'from_lang': from_lang,
|
|
|
|
| 22 |
return response.json()
|
| 23 |
|
| 24 |
def get_health():
|
| 25 |
+
response = requests.get(API_ENDPOINT, headers=headers)
|
| 26 |
print(response)
|
| 27 |
print(response.json())
|
| 28 |
return "TRUE"
|