Update main.py
Browse files
main.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
from fastapi import FastAPI
|
| 2 |
import requests
|
| 3 |
|
| 4 |
app = FastAPI()
|
|
@@ -17,10 +17,19 @@ def get_token():
|
|
| 17 |
|
| 18 |
try:
|
| 19 |
resp = requests.get(URL, headers=headers, timeout=20)
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
except requests.RequestException as e:
|
| 26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastapi import FastAPI, Response
|
| 2 |
import requests
|
| 3 |
|
| 4 |
app = FastAPI()
|
|
|
|
| 17 |
|
| 18 |
try:
|
| 19 |
resp = requests.get(URL, headers=headers, timeout=20)
|
| 20 |
+
|
| 21 |
+
# ููุง ุจูุฑุฌุน ููุณ ููุฏ ุงูุญุงูุฉ ุงููู ุฑุฌูุนู ุงูุณูุฑูุฑ ุงูุฃุตูู
|
| 22 |
+
content_type = resp.headers.get("Content-Type", "application/json")
|
| 23 |
+
return Response(
|
| 24 |
+
content=resp.text,
|
| 25 |
+
status_code=resp.status_code,
|
| 26 |
+
media_type=content_type
|
| 27 |
+
)
|
| 28 |
+
|
| 29 |
except requests.RequestException as e:
|
| 30 |
+
# ูู ุญุตู ุฎุทุฃ ูู ุงูุงุชุตุงู ููุณู ุฃู Timeout
|
| 31 |
+
return Response(
|
| 32 |
+
content=str(e),
|
| 33 |
+
status_code=500,
|
| 34 |
+
media_type="text/plain"
|
| 35 |
+
)
|