Remove cruft

This commit is contained in:
2025-04-12 12:54:58 -05:00
parent a7fccf728c
commit 90dc188dc8

View File

@@ -14,14 +14,13 @@ app = FastAPI()
logger = Logger() logger = Logger()
db = Database() db = Database()
domain_exclusions = DomainExclusions() # Initialize with default config path domain_exclusions = DomainExclusions()
@app.websocket("/ws") @app.websocket("/ws")
async def websocket_endpoint(websocket: WebSocket): async def websocket_endpoint(websocket: WebSocket):
await websocket.accept() await websocket.accept()
logger.info("New WebSocket connection established") logger.info("New WebSocket connection established")
# Create crawler instance outside the loop for reuse
async with AsyncWebCrawler() as crawler: async with AsyncWebCrawler() as crawler:
try: try:
while True: while True:
@@ -42,10 +41,8 @@ async def websocket_endpoint(websocket: WebSocket):
}) })
continue continue
# Crawl the URL to get title and content
try: try:
result = await crawler.arun(url=url) result = await crawler.arun(url=url)
# Get the first result from the container and access metadata
crawl_result = result[0] crawl_result = result[0]
title = crawl_result.metadata.get('title') or url.split("/")[-1] title = crawl_result.metadata.get('title') or url.split("/")[-1]
content = crawl_result.markdown content = crawl_result.markdown
@@ -54,7 +51,6 @@ async def websocket_endpoint(websocket: WebSocket):
title = url.split("/")[-1] title = url.split("/")[-1]
content = str(data) content = str(data)
# Store received data with crawled information
db.add_history( db.add_history(
url=url, url=url,
title=title, title=title,