Update app.py
Browse files
app.py
CHANGED
|
@@ -1,8 +1,19 @@
|
|
| 1 |
-
import os, json,
|
| 2 |
from typing import Dict, Any
|
| 3 |
from fastapi import FastAPI, Body, Request
|
| 4 |
from fastapi.middleware.cors import CORSMiddleware
|
| 5 |
from fastapi.responses import JSONResponse, PlainTextResponse
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
# ========= Config (set via Secrets) =========
|
| 8 |
TTS_BASE = os.getenv("TTS_BASE", "https://Percy3822-ActualTTS.hf.space")
|
|
|
|
| 1 |
+
import os, json,
|
| 2 |
from typing import Dict, Any
|
| 3 |
from fastapi import FastAPI, Body, Request
|
| 4 |
from fastapi.middleware.cors import CORSMiddleware
|
| 5 |
from fastapi.responses import JSONResponse, PlainTextResponse
|
| 6 |
+
import httpx
|
| 7 |
+
|
| 8 |
+
# Stable AsyncClient with explicit 4-part timeout
|
| 9 |
+
_client = httpx.AsyncClient(
|
| 10 |
+
timeout=httpx.Timeout(
|
| 11 |
+
connect=15.0, # max time to connect
|
| 12 |
+
read=30.0, # max time to wait for response data
|
| 13 |
+
write=15.0, # max time to send request body
|
| 14 |
+
pool=15.0 # max time to get a connection from the pool
|
| 15 |
+
)
|
| 16 |
+
)
|
| 17 |
|
| 18 |
# ========= Config (set via Secrets) =========
|
| 19 |
TTS_BASE = os.getenv("TTS_BASE", "https://Percy3822-ActualTTS.hf.space")
|