feat: implement FastAPI service to expose Shopee commission scraping automation via REST API

This commit is contained in:
Victor Phan
2026-07-21 10:02:51 +07:00
parent 6156bc7bb3
commit adbfb43a48
3 changed files with 59 additions and 15 deletions
+6 -4
View File
@@ -26,13 +26,15 @@ async def get_commission_endpoint(req: CommissionRequest):
bot = ShopeeBot(device_ip=target_ip)
result = bot.get_commission(req.link)
result = bot.get_commission_rate(req.link)
# Nếu đã có status thì gộp thẳng các thuộc tính của result vào JSON trả về
if isinstance(result, dict) and "status" in result:
return result
return {
"status": "success",
"link": req.link,
"commission": result,
"connected_ip": target_ip if target_ip else "auto-detect"
"commission": result
}
except Exception as e:
logging.error(f"Lỗi API: {str(e)}")