Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1720,9 +1720,8 @@ async def process_incoming_message(from_number: str, msg: dict):
|
|
| 1720 |
current_menu='product_inquiry',
|
| 1721 |
current_menu_options=list(MENU_CONFIG['product_inquiry']['option_descriptions'].values())
|
| 1722 |
)
|
| 1723 |
-
|
| 1724 |
await send_product_image_with_caption(from_number, exact_match, user_context)
|
| 1725 |
-
send_whatsjet_message(from_number, response)
|
| 1726 |
return
|
| 1727 |
|
| 1728 |
# --- END NEW LOGIC ---
|
|
@@ -2519,15 +2518,19 @@ load_products_data()
|
|
| 2519 |
def get_product_image_path(product_name: str) -> str:
|
| 2520 |
"""
|
| 2521 |
Get the public image URL for a product based on its name, robust to formatting, preserving dashes.
|
|
|
|
|
|
|
| 2522 |
"""
|
| 2523 |
try:
|
| 2524 |
-
# Normalize: lowercase, remove spaces, underscores, and dots, but keep dashes
|
| 2525 |
def normalize(name):
|
| 2526 |
return re.sub(r'[\s_\.]', '', name).lower()
|
| 2527 |
normalized_name = normalize(product_name)
|
| 2528 |
image_extensions = ['.png', '.jpg', '.jpeg', '.webp']
|
| 2529 |
base_url = "https://amgocus.com/uploads/images/"
|
| 2530 |
import requests
|
|
|
|
|
|
|
|
|
|
| 2531 |
# Try normalized name (with dashes preserved)
|
| 2532 |
for ext in image_extensions:
|
| 2533 |
image_url = f"{base_url}{normalized_name}{ext}"
|
|
@@ -3592,4 +3595,4 @@ if __name__ == "__main__":
|
|
| 3592 |
|
| 3593 |
# Launch FastAPI app
|
| 3594 |
import uvicorn
|
| 3595 |
-
uvicorn.run(app, host="0.0.0.0", port=7860)
|
|
|
|
| 1720 |
current_menu='product_inquiry',
|
| 1721 |
current_menu_options=list(MENU_CONFIG['product_inquiry']['option_descriptions'].values())
|
| 1722 |
)
|
| 1723 |
+
# Only send one reply: image+caption if possible, else text
|
| 1724 |
await send_product_image_with_caption(from_number, exact_match, user_context)
|
|
|
|
| 1725 |
return
|
| 1726 |
|
| 1727 |
# --- END NEW LOGIC ---
|
|
|
|
| 2518 |
def get_product_image_path(product_name: str) -> str:
|
| 2519 |
"""
|
| 2520 |
Get the public image URL for a product based on its name, robust to formatting, preserving dashes.
|
| 2521 |
+
cPanel public URL format: https://amgocus.com/uploads/images/<normalized_name>.<ext>
|
| 2522 |
+
Normalized: lowercase, remove spaces/underscores/dots, preserve dashes.
|
| 2523 |
"""
|
| 2524 |
try:
|
|
|
|
| 2525 |
def normalize(name):
|
| 2526 |
return re.sub(r'[\s_\.]', '', name).lower()
|
| 2527 |
normalized_name = normalize(product_name)
|
| 2528 |
image_extensions = ['.png', '.jpg', '.jpeg', '.webp']
|
| 2529 |
base_url = "https://amgocus.com/uploads/images/"
|
| 2530 |
import requests
|
| 2531 |
+
# Log for respiraaidplus.png check
|
| 2532 |
+
if normalized_name == "respiraaidplus":
|
| 2533 |
+
logger.info(f"[Image] Checking cPanel URL for respiraaidplus: {base_url}respiraaidplus.png")
|
| 2534 |
# Try normalized name (with dashes preserved)
|
| 2535 |
for ext in image_extensions:
|
| 2536 |
image_url = f"{base_url}{normalized_name}{ext}"
|
|
|
|
| 3595 |
|
| 3596 |
# Launch FastAPI app
|
| 3597 |
import uvicorn
|
| 3598 |
+
uvicorn.run(app, host="0.0.0.0", port=7860)
|