etukurudinesh commited on
Commit
191e833
·
1 Parent(s): d9c4778

fix: app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -6
app.py CHANGED
@@ -3,11 +3,20 @@ from pydantic import BaseModel, HttpUrl
3
  from typing import List, Dict, Optional
4
  import asyncio
5
  from main import WebScrapingOrchestrator
 
 
 
 
 
 
 
 
6
 
7
  app = FastAPI(
8
  title="Advanced Web Scraper for LLM",
9
  description="Scrape, analyze, and store web content optimized for LLM consumption",
10
- version="1.0.0"
 
11
  )
12
 
13
  # Global orchestrator instance
@@ -200,11 +209,6 @@ def _assess_difficulty(metadata: Dict) -> str:
200
  else:
201
  return "advanced"
202
 
203
- @app.on_event("shutdown")
204
- async def shutdown_event():
205
- """Clean up on shutdown"""
206
- orchestrator.close_connections()
207
-
208
  # Run the API
209
  if __name__ == "__main__":
210
  import uvicorn
 
3
  from typing import List, Dict, Optional
4
  import asyncio
5
  from main import WebScrapingOrchestrator
6
+ from contextlib import asynccontextmanager
7
+
8
+ @asynccontextmanager
9
+ async def lifespan(app: FastAPI):
10
+ # Startup code (if any) goes here
11
+ yield
12
+ # Shutdown code goes here
13
+ await orchestrator.close_connections()
14
 
15
  app = FastAPI(
16
  title="Advanced Web Scraper for LLM",
17
  description="Scrape, analyze, and store web content optimized for LLM consumption",
18
+ version="1.0.0",
19
+ lifespan = lifespan,
20
  )
21
 
22
  # Global orchestrator instance
 
209
  else:
210
  return "advanced"
211
 
 
 
 
 
 
212
  # Run the API
213
  if __name__ == "__main__":
214
  import uvicorn