Spaces:
Running
Running
Fixing server error
Browse files
app.py
CHANGED
@@ -25,10 +25,11 @@ def get_token() -> str:
|
|
25 |
)
|
26 |
|
27 |
|
28 |
-
def get_headers() -> dict:
|
29 |
creds = load_default_credentials()
|
30 |
return {
|
31 |
"Authorization": f"Bearer {creds.access_token}",
|
|
|
32 |
"Accept": "application/json",
|
33 |
"Content-Type": "application/json",
|
34 |
}
|
@@ -36,7 +37,7 @@ def get_headers() -> dict:
|
|
36 |
|
37 |
def proxy(request: httpx.Request, model_info: dict) -> httpx.Request:
|
38 |
request.url = request.url.copy_with(path=model_info["endpoint"])
|
39 |
-
request.headers.update(get_headers())
|
40 |
return request
|
41 |
|
42 |
|
|
|
25 |
)
|
26 |
|
27 |
|
28 |
+
def get_headers(host: str) -> dict:
|
29 |
creds = load_default_credentials()
|
30 |
return {
|
31 |
"Authorization": f"Bearer {creds.access_token}",
|
32 |
+
"Host": host,
|
33 |
"Accept": "application/json",
|
34 |
"Content-Type": "application/json",
|
35 |
}
|
|
|
37 |
|
38 |
def proxy(request: httpx.Request, model_info: dict) -> httpx.Request:
|
39 |
request.url = request.url.copy_with(path=model_info["endpoint"])
|
40 |
+
request.headers.update(get_headers(host=model_info["host"].replace("https://", "")))
|
41 |
return request
|
42 |
|
43 |
|