Spaces:
Running
Running
Prathamesh Sable
commited on
Commit
·
008f4ec
1
Parent(s):
d616264
bug fix
Browse files- routers/product.py +2 -2
- utils/fetch_data.py +1 -1
routers/product.py
CHANGED
|
@@ -2,7 +2,7 @@ import io
|
|
| 2 |
from fastapi import APIRouter, Request, HTTPException
|
| 3 |
from fastapi.responses import JSONResponse
|
| 4 |
from typing import List, Dict, Any
|
| 5 |
-
from logger_manager import log_info, log_error
|
| 6 |
from PIL import Image
|
| 7 |
import os
|
| 8 |
from services.product_service import ProductService
|
|
@@ -203,7 +203,7 @@ async def find_product_by_barcode(barcode_number: str):
|
|
| 203 |
product_data = await fetch_product_data_from_api(barcode_number)
|
| 204 |
if product_data:
|
| 205 |
# dump to log file
|
| 206 |
-
log_debug(
|
| 207 |
return JSONResponse(product_data)
|
| 208 |
else:
|
| 209 |
raise HTTPException(status_code=404, detail=f"Product not found for barcode: {barcode_number}")
|
|
|
|
| 2 |
from fastapi import APIRouter, Request, HTTPException
|
| 3 |
from fastapi.responses import JSONResponse
|
| 4 |
from typing import List, Dict, Any
|
| 5 |
+
from logger_manager import log_debug, log_info, log_error
|
| 6 |
from PIL import Image
|
| 7 |
import os
|
| 8 |
from services.product_service import ProductService
|
|
|
|
| 203 |
product_data = await fetch_product_data_from_api(barcode_number)
|
| 204 |
if product_data:
|
| 205 |
# dump to log file
|
| 206 |
+
log_debug(str(product_data))
|
| 207 |
return JSONResponse(product_data)
|
| 208 |
else:
|
| 209 |
raise HTTPException(status_code=404, detail=f"Product not found for barcode: {barcode_number}")
|
utils/fetch_data.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
import requests
|
| 2 |
from fastapi import HTTPException
|
| 3 |
|
| 4 |
-
def fetch_product_data_from_api(barcode):
|
| 5 |
url = f"https://india.openfoodfacts.org/api/v2/product/{barcode}.json"
|
| 6 |
response = requests.get(url)
|
| 7 |
if response.status_code != 200:
|
|
|
|
| 1 |
import requests
|
| 2 |
from fastapi import HTTPException
|
| 3 |
|
| 4 |
+
async def fetch_product_data_from_api(barcode):
|
| 5 |
url = f"https://india.openfoodfacts.org/api/v2/product/{barcode}.json"
|
| 6 |
response = requests.get(url)
|
| 7 |
if response.status_code != 200:
|