Files
hufs-notice-crawler/app/main.py
nkey ca460453af
All checks were successful
hufs-notice-crawler-cicd / build_push_deploy (push) Successful in 8m35s
Feat: [main] hufs-notice-crawler CI/CD까지 구현 완료
2026-03-17 17:18:16 +09:00

31 lines
737 B
Python

from contextlib import asynccontextmanager
from fastapi import Depends, FastAPI
from sqlalchemy.orm import Session
from app.config import get_settings
from app.db import Base, engine, get_db
from app.schemas import CrawlResponse
from app.service import CrawlService
@asynccontextmanager
async def lifespan(_: FastAPI):
Base.metadata.create_all(bind=engine)
yield
settings = get_settings()
app = FastAPI(title=settings.app_name, lifespan=lifespan)
@app.get("/health")
def health() -> dict[str, str]:
return {"status": "ok"}
@app.post("/api/v1/crawl", response_model=CrawlResponse)
def crawl_notices(db: Session = Depends(get_db)) -> CrawlResponse:
service = CrawlService(db)
return service.crawl_new_posts()