Spaces:
Runtime error
Runtime error
import threading | |
from fastapi import FastAPI | |
from datetime import datetime | |
from scraper import main # our scraping entrypoint | |
app = FastAPI() | |
_started = False | |
def kick_off_scraper(): | |
global _started | |
if not _started: | |
_started = True | |
thread = threading.Thread(target=main, daemon=True) | |
thread.start() | |
def read_root(): | |
return { | |
"status": "scraper is running in background", | |
"timestamp": datetime.utcnow().isoformat() + "Z" | |
} | |