Spaces:
Sleeping
Sleeping
Upload api_logic.py
Browse files- src/api_logic.py +7 -6
src/api_logic.py
CHANGED
|
@@ -4,11 +4,11 @@ from google.ads.googleads.client import GoogleAdsClient
|
|
| 4 |
from google.ads.googleads.errors import GoogleAdsException
|
| 5 |
import os
|
| 6 |
|
| 7 |
-
#
|
| 8 |
-
|
| 9 |
-
#
|
| 10 |
-
|
| 11 |
-
|
| 12 |
|
| 13 |
# # ADD
|
| 14 |
# import yaml
|
|
@@ -29,8 +29,9 @@ import os
|
|
| 29 |
# with open("google-ads.yaml", "w", encoding="utf-8") as f:
|
| 30 |
# f.write(yaml_str)#
|
| 31 |
|
|
|
|
| 32 |
|
| 33 |
-
client = GoogleAdsClient.load_from_storage("
|
| 34 |
keyword_plan_idea_service = client.get_service("KeywordPlanIdeaService")
|
| 35 |
|
| 36 |
class KeywordRequestModel(BaseModel):
|
|
|
|
| 4 |
from google.ads.googleads.errors import GoogleAdsException
|
| 5 |
import os
|
| 6 |
|
| 7 |
+
# Read yaml from Secrets in HF
|
| 8 |
+
yaml_str = os.environ["GOOGLE_ADS_YAML"]
|
| 9 |
+
# Write YAML to a temporary file
|
| 10 |
+
with open("google-ads.yaml", "w") as f:
|
| 11 |
+
f.write(yaml_str)
|
| 12 |
|
| 13 |
# # ADD
|
| 14 |
# import yaml
|
|
|
|
| 29 |
# with open("google-ads.yaml", "w", encoding="utf-8") as f:
|
| 30 |
# f.write(yaml_str)#
|
| 31 |
|
| 32 |
+
#client = GoogleAdsClient.load_from_storage("src/google-ads.yaml")
|
| 33 |
|
| 34 |
+
client = GoogleAdsClient.load_from_storage("google-ads.yaml")
|
| 35 |
keyword_plan_idea_service = client.get_service("KeywordPlanIdeaService")
|
| 36 |
|
| 37 |
class KeywordRequestModel(BaseModel):
|