Created
November 13, 2025 22:05
-
-
Save koorukuroo/feaa2e2389c45aeedfa23082a1023e1c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from fastapi import FastAPI | |
| from pydantic import BaseModel | |
| import os | |
| app = FastAPI( | |
| title="FastAPI on EKS", | |
| description="Simple API for K8s deployment", | |
| version="1.0.0" | |
| ) | |
| class Item(BaseModel): | |
| name: str # 아이템 이름 | |
| description: str | None = None # 설명 (옵션) | |
| price: float # 가격 | |
| # 기본 엔드포인트 | |
| @app.get("/") | |
| async def root(): | |
| return { | |
| "message": "Hello from FastAPI on EKS!", # 간단한 메시지 | |
| "environment": os.getenv("ENV", "dev") # ENV 환경변수 (기본값 dev) | |
| } | |
| # 헬스체크 엔드포인트 | |
| @app.get("/health") | |
| async def health_check(): | |
| return {"status": "healthy"} # 따옴표 오류 수정 | |
| # POST 요청으로 아이템 생성 | |
| @app.post("/items/") | |
| async def create_item(item: Item): | |
| return { | |
| "item": item, # 입력받은 아이템 | |
| "created": True # 생성 여부 표시 | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment