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
| import json, boto3 | |
| bedrock_agent = boto3.client( | |
| 'bedrock-agent-runtime', | |
| region_name='us-east-1' | |
| ) | |
| def lambda_handler(event, context): | |
| question = json.loads(event['body'])['question'] |
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
| import json, uuid, datetime | |
| # In-memory store (DynamoDB로 교체 예정) | |
| store = {} | |
| def lambda_handler(event, context): | |
| method = event['httpMethod'] | |
| path_params = event.get('pathParameters') or {} | |
| query_params = event.get('queryStringParameters') or {} |
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
| import json | |
| import boto3 | |
| import uuid | |
| from decimal import Decimal | |
| # DynamoDB 설정 | |
| dynamodb = boto3.resource('dynamodb') | |
| table = dynamodb.Table('ItemsTable') # 테이블 이름 수정 | |
| # JSON 직렬화용 (Decimal → float) |
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
| import json | |
| def lambda_handler(event, context): | |
| return { | |
| 'statusCode': 200, | |
| 'headers': { | |
| 'Content-Type': 'application/json', | |
| 'Access-Control-Allow-Origin': '*' | |
| }, | |
| 'body': json.dumps({ |
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
| import json | |
| import boto3 | |
| from PIL import Image | |
| import io | |
| import urllib.parse | |
| s3 = boto3.client('s3') | |
| # 원하는 사이즈 설정 | |
| MAX_WIDTH = 300 |
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
| @app.put("/api/v1/requests/{request_id}/status", | |
| response_model=RequestResponse, | |
| tags=["점검 요청"]) | |
| def update_status(request_id: int, | |
| update: StatusUpdate, | |
| db: Session = Depends(get_db)): | |
| req = db.query(InspectionRequest) \ | |
| .filter(InspectionRequest.id == request_id) \ | |
| .first() | |
| if not req: |
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
| @app.get("/api/v1/requests", | |
| response_model=list[RequestResponse]) | |
| def list_requests( | |
| status: Optional[str] = Query(None), | |
| priority: Optional[str] = Query(None), | |
| page: int = Query(1, ge=1, | |
| description="페이지 번호 (1부터 시작)"), | |
| limit: int = Query(10, ge=1, le=100, | |
| description="페이지당 항목 수 (최대 100)"), | |
| db: Session = Depends(get_db), |
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
| @app.get("/api/v1/requests", | |
| response_model=list[RequestResponse], | |
| tags=["점검 요청"]) | |
| def list_requests( | |
| status: Optional[str] = Query( | |
| None, | |
| description="상태 필터 (PENDING, ASSIGNED 등)" | |
| ), | |
| priority: Optional[str] = Query( | |
| None, |
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
| @app.post("/api/v1/requests", | |
| response_model=RequestResponse, | |
| status_code=201, tags=["점검 요청"]) | |
| def create_request(req: RequestCreate, | |
| db: Session = Depends(get_db)): | |
| # 설비 존재 여부 확인 | |
| equipment = db.query(Equipment) \ | |
| .filter(Equipment.id == req.equipment_id).first() | |
| if not equipment: | |
| raise HTTPException( |
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
| apiVersion: apps/v1 | |
| kind: Deployment | |
| metadata: | |
| name: fastapi-deployment | |
| namespace: default | |
| spec: | |
| replicas: 3 | |
| selector: | |
| matchLabels: | |
| app: fastapi |
NewerOlder