Skip to content

sungwook-practice/fastapi-async

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

개요

chatgpt 텍스트

  • 동기
FastAPI application with a /hello endpoint that returns a JSON object with a "hello" key and "world" value, and sleeps for 5 second before returning the response:
  • 비동기
FastAPI application with a /hello async endpoint that returns a JSON object with a "hello" key and "world" value, and sleeps for 5 second before returning the response:

실행방법

  • 파이썬 패키지 설치
cd ./app
pip install -r requirements.txt
  • 로컬 실행
cd ./app

# sync
uvicorn --host 0.0.0.0 --port 8080 main:app --reload

# 잘못사용한 async_main
uvicorn --host 0.0.0.0 --port 8081 uncorret_async_main:app --reload

# 올바른 async
uvicorn --host 0.0.0.0 --port 8082 async_main:app --reload

쿠버네티스 실행

  • 이미지 생성
docker build -t local-test:v1 .
  • 쿠버네티스 deploy
kubectl apply -f ./k8s/deploy.yaml
  • 삭제
kubectl delete -f ./k8s/deploy.yaml

참고자료