Update app/page_speed/config.py
Browse files- app/page_speed/config.py +9 -23
app/page_speed/config.py
CHANGED
|
@@ -12,18 +12,13 @@ class Settings(BaseSettings):
|
|
| 12 |
pagespeed_api_key: str
|
| 13 |
gemini_api_key: str
|
| 14 |
|
| 15 |
-
# Qdrant (vector DB) connection
|
| 16 |
qdrant_url: str
|
| 17 |
qdrant_api_key: str
|
| 18 |
-
# Optional timeout (seconds) to use when creating clients or making calls
|
| 19 |
qdrant_timeout: int = 60
|
| 20 |
|
| 21 |
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 22 |
-
#
|
| 23 |
-
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 24 |
-
|
| 25 |
-
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 26 |
-
# MongoDB Configuration (Local)
|
| 27 |
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 28 |
mongo_user: str
|
| 29 |
mongo_password: str
|
|
@@ -35,30 +30,24 @@ class Settings(BaseSettings):
|
|
| 35 |
def mongo_uri(self) -> str:
|
| 36 |
"""
|
| 37 |
Return a mongodb+srv URI for use with MongoClient.
|
| 38 |
-
Do NOT include ssl=true in the URI; we'll pass tls and CA explicitly to MongoClient.
|
| 39 |
"""
|
| 40 |
pw = quote_plus(self.mongo_password)
|
| 41 |
-
# keep retryWrites and w=majority; do not append ssl/tls params here
|
| 42 |
return f"mongodb+srv://{self.mongo_user}:{pw}@{self.mongo_host}/{self.mongo_db}?retryWrites=true&w=majority"
|
| 43 |
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 47 |
-
# local MongoDB Connection
|
| 48 |
-
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 49 |
-
|
| 50 |
-
# return f"mongodb://localhost:27017/{self.mongo_db}"
|
| 51 |
-
|
| 52 |
-
|
| 53 |
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 54 |
# FastAPI Server Configuration
|
| 55 |
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 56 |
host: str = "0.0.0.0"
|
| 57 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
debug: bool = False
|
| 59 |
|
| 60 |
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 61 |
-
# App Metadata
|
| 62 |
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 63 |
app_name: str = "PageSpeed Insights Report Generator"
|
| 64 |
app_version: str = "1.0.0"
|
|
@@ -67,9 +56,6 @@ class Settings(BaseSettings):
|
|
| 67 |
"using Google's APIs and Gemini AI"
|
| 68 |
)
|
| 69 |
|
| 70 |
-
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 71 |
-
# Tell Pydantic to load from .env and ignore extras
|
| 72 |
-
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 73 |
model_config = SettingsConfigDict(
|
| 74 |
env_file=".env",
|
| 75 |
env_file_encoding="utf-8",
|
|
|
|
| 12 |
pagespeed_api_key: str
|
| 13 |
gemini_api_key: str
|
| 14 |
|
| 15 |
+
# Qdrant (vector DB) connection
|
| 16 |
qdrant_url: str
|
| 17 |
qdrant_api_key: str
|
|
|
|
| 18 |
qdrant_timeout: int = 60
|
| 19 |
|
| 20 |
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 21 |
+
# MongoDB Configuration
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 23 |
mongo_user: str
|
| 24 |
mongo_password: str
|
|
|
|
| 30 |
def mongo_uri(self) -> str:
|
| 31 |
"""
|
| 32 |
Return a mongodb+srv URI for use with MongoClient.
|
|
|
|
| 33 |
"""
|
| 34 |
pw = quote_plus(self.mongo_password)
|
|
|
|
| 35 |
return f"mongodb+srv://{self.mongo_user}:{pw}@{self.mongo_host}/{self.mongo_db}?retryWrites=true&w=majority"
|
| 36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 38 |
# FastAPI Server Configuration
|
| 39 |
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 40 |
host: str = "0.0.0.0"
|
| 41 |
+
|
| 42 |
+
# --- FIX IS HERE ---
|
| 43 |
+
# 1. Use "PORT" (uppercase) to match Cloud env variables
|
| 44 |
+
# 2. Default to 7860 to match Hugging Face requirements
|
| 45 |
+
port: int = int(os.getenv("PORT", 7860))
|
| 46 |
+
|
| 47 |
debug: bool = False
|
| 48 |
|
| 49 |
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 50 |
+
# App Metadata
|
| 51 |
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 52 |
app_name: str = "PageSpeed Insights Report Generator"
|
| 53 |
app_version: str = "1.0.0"
|
|
|
|
| 56 |
"using Google's APIs and Gemini AI"
|
| 57 |
)
|
| 58 |
|
|
|
|
|
|
|
|
|
|
| 59 |
model_config = SettingsConfigDict(
|
| 60 |
env_file=".env",
|
| 61 |
env_file_encoding="utf-8",
|