FASTAPI 시작하기 (1)

code_able·2023년 3월 11일
0

python 인터프리터는 c 컴파일러로 작동하여 속도의 한계가 있다.
따라서 python의 웹 프레임워크 장고 같은 것들은 spring boot나 nodejs등의 웹 프레임워크의 성능을 따라갈수 없었다.
하지만 이젠 아니다 fast api가 나오고 나서부턴

FASTAPI의 철학

  • High Performance
  • Easy to Learn
  • Fast to Code
  • Ready for Production

FASTAPI의 장점

  • 비동기 프로그래밍 지원 (이제 celery를 안써도 된다!)
  • Pydanic을 통한 데이터 유효성 검증
  • swgger api 명세 자동 생성

설치

pip install fastapi uvicorn

코드

app.py
from fastapi import FastAPI

app = FastAPI()

@app.get("/")
def hello():
    return {"Hello": "World"}

실행

uvicorn main:app --reload

웹에서 hello world 확인

http://127.0.0.1:8000

swagger 확인

http://127.0.0.1:8000/docs
profile
할수 있다! code able

0개의 댓글