불필요 main api 정리
This commit is contained in:
1 parent
3d1f8683a4
commit
cb5dd5f25f
4 files changed
+44
-113
No files matched your search
+1
-37
@@ -1,5 +1,4 @@
|
||||
import os
|
||||
from typing import Optional
|
||||
from fastapi import FastAPI, HTTPException
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
from fastapi.staticfiles import StaticFiles
|
||||
@@ -7,7 +6,7 @@ from fastapi.responses import FileResponse
|
||||
from dotenv import load_dotenv
|
||||
import uvicorn
|
||||
|
||||
from models import RealEstateQuery, ParsedRealEstate
|
||||
from models import RealEstateQuery
|
||||
from openai_parser import OpenAIParser
|
||||
from public_data_api import PublicDataAPIClient
|
||||
|
||||
@@ -39,40 +38,6 @@ async def serve_index():
|
||||
"""메인 페이지 제공"""
|
||||
return FileResponse("../frontend/index.html")
|
||||
|
||||
@app.post("/api/parse", response_model=ParsedRealEstate)
|
||||
async def parse_real_estate(query: RealEstateQuery):
|
||||
"""자연어 입력을 파싱하여 부동산 정보 추출"""
|
||||
if not parser:
|
||||
raise HTTPException(
|
||||
status_code=500,
|
||||
detail="OpenAI API key not configured. Please set OPENAI_API_KEY in .env file"
|
||||
)
|
||||
|
||||
try:
|
||||
result = await parser.parse_real_estate_query(query.text)
|
||||
return result
|
||||
except Exception as e:
|
||||
raise HTTPException(status_code=500, detail=str(e))
|
||||
|
||||
@app.get("/api/real-estate-data")
|
||||
async def get_real_estate_listings(
|
||||
property_type: str = "아파트",
|
||||
transaction_type: str = "매매",
|
||||
region_code: str = "11680",
|
||||
deal_ymd: Optional[str] = None
|
||||
):
|
||||
"""공공데이터 API를 통한 실거래가 조회"""
|
||||
try:
|
||||
data = public_data_client.get_real_estate_data(
|
||||
property_type=property_type,
|
||||
transaction_type=transaction_type,
|
||||
region_code=region_code,
|
||||
deal_ymd=deal_ymd
|
||||
)
|
||||
return {"data": data, "count": len(data)}
|
||||
except Exception as e:
|
||||
raise HTTPException(status_code=500, detail=str(e))
|
||||
|
||||
@app.post("/api/search")
|
||||
async def search_real_estate(query: RealEstateQuery):
|
||||
"""자연어 검색 후 실거래가 데이터 조회"""
|
||||
@@ -94,7 +59,6 @@ async def search_real_estate(query: RealEstateQuery):
|
||||
transaction_type=parsed.transaction_type,
|
||||
region_code=parsed.region_code
|
||||
)
|
||||
print(listings)
|
||||
|
||||
return {
|
||||
"parsed": parsed,
|
||||
|
||||
Reference in new issue
Block a user