(pip, python 설치가 되어있어야 한다.)
pip install fastapi
pip install uvicorn
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
async def root():
return {"message": "Hello World"}
해당 프로젝트 폴더내에서, 라이브 서버를 실행
uvicorn index:app --reload
uvicorn은 저수준 서버.
index는 index.py의 파일명
app은 index.py내부의 app = FastAPI() 로 만든 인스턴스
http://127.0.0.1:8000
현재 app.get 어노테이션에서 /로만 설정되어있어서 해당 창에는 "{"message": "Hello World"}"라는 글자만 나타나는 것을 확인 할 수 있다.