Update main.py
Browse files
main.py
CHANGED
|
@@ -1,21 +1,16 @@
|
|
| 1 |
import os
|
| 2 |
from fastapi import FastAPI, HTTPException
|
| 3 |
from pydantic import BaseModel, Field
|
| 4 |
-
from typing import List
|
| 5 |
-
import asyncio
|
| 6 |
-
import nest_asyncio
|
| 7 |
from crawl4ai import AsyncWebCrawler
|
| 8 |
-
from crawl4ai.extraction_strategy import
|
| 9 |
import json
|
| 10 |
-
import time
|
| 11 |
from dotenv import load_dotenv
|
| 12 |
|
| 13 |
load_dotenv() # Load environment variables from .env file
|
| 14 |
|
| 15 |
app = FastAPI()
|
| 16 |
|
| 17 |
-
nest_asyncio.apply()
|
| 18 |
-
|
| 19 |
class CrawlerInput(BaseModel):
|
| 20 |
url: str = Field(..., description="URL to crawl")
|
| 21 |
columns: List[str] = Field(..., description="List of required columns")
|
|
@@ -57,4 +52,4 @@ async def test():
|
|
| 57 |
|
| 58 |
if __name__ == "__main__":
|
| 59 |
import uvicorn
|
| 60 |
-
uvicorn.run(app, host="0.0.0.0", port=8000)
|
|
|
|
| 1 |
import os
|
| 2 |
from fastapi import FastAPI, HTTPException
|
| 3 |
from pydantic import BaseModel, Field
|
| 4 |
+
from typing import List
|
|
|
|
|
|
|
| 5 |
from crawl4ai import AsyncWebCrawler
|
| 6 |
+
from crawl4ai.extraction_strategy import LLMExtractionStrategy
|
| 7 |
import json
|
|
|
|
| 8 |
from dotenv import load_dotenv
|
| 9 |
|
| 10 |
load_dotenv() # Load environment variables from .env file
|
| 11 |
|
| 12 |
app = FastAPI()
|
| 13 |
|
|
|
|
|
|
|
| 14 |
class CrawlerInput(BaseModel):
|
| 15 |
url: str = Field(..., description="URL to crawl")
|
| 16 |
columns: List[str] = Field(..., description="List of required columns")
|
|
|
|
| 52 |
|
| 53 |
if __name__ == "__main__":
|
| 54 |
import uvicorn
|
| 55 |
+
uvicorn.run(app, host="0.0.0.0", port=8000, loop="asyncio")
|