Prathamesh Sable commited on
Commit
251553c
·
1 Parent(s): 8986db1

added api to get product details from vuforia target id vuforia_id in DB marker tbl

Browse files
Files changed (1) hide show
  1. routers/product.py +12 -1
routers/product.py CHANGED
@@ -279,4 +279,15 @@ async def get_image(image_name: str):
279
  if os.path.exists(image_path):
280
  return FileResponse(image_path, media_type="image/jpeg")
281
  else:
282
- return JSONResponse({"error": "Image not found"}, status_code=404)
 
 
 
 
 
 
 
 
 
 
 
 
279
  if os.path.exists(image_path):
280
  return FileResponse(image_path, media_type="image/jpeg")
281
  else:
282
+ return JSONResponse({"error": "Image not found"}, status_code=404)
283
+
284
+
285
+ # In your API, add an endpoint like:
286
+ @router.get("/marker/{vuforia_id}")
287
+ async def get_product_by_marker(vuforia_id: str, db: Session = Depends(get_db)):
288
+ marker = db.query(Marker).filter(Marker.vuforia_id == vuforia_id).first()
289
+ if not marker:
290
+ raise HTTPException(status_code=404, detail="Target not found")
291
+
292
+ product = db.query(Product).filter(Product.id == marker.product_id).first()
293
+ return product