30 lines
624 B
Python
30 lines
624 B
Python
from contextlib import asynccontextmanager
|
|
|
|
from dotenv import load_dotenv
|
|
from fastapi import FastAPI
|
|
|
|
from .storage import get_storage
|
|
from .views import app_router
|
|
|
|
load_dotenv()
|
|
|
|
|
|
@asynccontextmanager
|
|
async def lifespan(app: FastAPI):
|
|
get_storage().init_db()
|
|
yield
|
|
|
|
|
|
api = FastAPI(
|
|
title="Temu Scraper API",
|
|
description=(
|
|
"POST endpoints run expensive Apify scrapers and persist results with timestamps. "
|
|
"GET endpoints search the local FTS index only."
|
|
),
|
|
docs_url="/docs",
|
|
redoc_url="/redoc",
|
|
lifespan=lifespan,
|
|
)
|
|
|
|
api.include_router(app_router, tags=["temu_scraper"])
|