mydatascraper/competitor_compare
0
1import sys
2import asyncio
3import os
4
5# ── Windows event loop fix (not needed on HF Linux, but safe to keep) ────────
6if sys.platform == "win32":
7 asyncio.set_event_loop_policy(asyncio.WindowsProactorEventLoopPolicy())
8
9import uvicorn
10
11
12if __name__ == "__main__":
13 port = int(os.environ.get("PORT", 7860))
14
15 print("🚀 Grocery Price Comparison API")
16 print("=" * 50)
17 print(f"Platform: {sys.platform}")
18 print(f"Port: {port}")
19 print(f"Python: {sys.version}")
20 print(f"\n📍 Docs: http://0.0.0.0:{port}/docs")
21 print(f"📍 Try: http://0.0.0.0:{port}/api/v1/compare?product=whole+milk")
22 print("=" * 50 + "\n")
23
24 uvicorn.run(
25 "app.main:app",
26 host="0.0.0.0",
27 port=port,
28 reload=False,
29 workers=1, # Single worker — Playwright uses lots of memory
30 )