갑자기 세워진 Fastapi.
환경 준비 $ pipenv shell
$ pipenv install fastapi uvicorn
소스 코드 
요점:
$ pipenv shell
$ pipenv install fastapi uvicorn
요점:
from fastapi import FastAPI
from pydantic import BaseModel
import dataclasses
import uuid
class UserInput(BaseModel):
    name: str
@dataclasses.dataclass
class User:
    id: str
    name: str
data = dict()
app = FastAPI()
@app.post("/users/")
async def create_user(user_input: UserInput) -> User:
    user_id = str(uuid.uuid4())
    user = User(user_id,user_input.name)
    global data
    data[user_id] = user
    print(user_id)
    return user
@app.get("/users/{user_id}")
async def read_user(user_id: str) -> User:
    return data[user_id]
@app.delete("/users/{user_id}")
async def delete_user(user_id: str) -> None:
    del data[user_id]
부팅 방법 
요점
$ uvicorn main:app --port=8080 --host=0.0.0.0
개발용 리로드.$ uvicorn main:app --reload --port=8080 --host=0.0.0.0
동작 확인 
 
 
컨테이너화 
DockerfileFROM python:3.6-slim
COPY Pipfile .
COPY Pipfile.lock .
RUN pip install pipenv --no-cache-dir
RUN pipenv sync --system  
COPY main.py .
CMD pipenv run uvicorn main:app --port=8080 --host=0.0.0.0
 $ docker build -t fastapi_test .
$ docker run --rm -p 8080:8080 fastapi_test
                
                    
        
    
    
    
    
    
                
                
                
                
                    
                        
                            
                            
                            Reference
                            
                            이 문제에 관하여(갑자기 세워진 Fastapi.), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
                                
                                https://qiita.com/kotauchisunsun/items/afe597084886a6a82980
                            
                            
                            
                                텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
                            
                            
                                
                                
                                
                                
                                
                                우수한 개발자 콘텐츠 발견에 전념
                                (Collection and Share based on the CC Protocol.)
                            
                            
                        
                    
                
                
                
            
Dockerfile
FROM python:3.6-slim
COPY Pipfile .
COPY Pipfile.lock .
RUN pip install pipenv --no-cache-dir
RUN pipenv sync --system  
COPY main.py .
CMD pipenv run uvicorn main:app --port=8080 --host=0.0.0.0
 $ docker build -t fastapi_test .
$ docker run --rm -p 8080:8080 fastapi_test
                Reference
이 문제에 관하여(갑자기 세워진 Fastapi.), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/kotauchisunsun/items/afe597084886a6a82980텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
                                
                                
                                
                                
                                
                                우수한 개발자 콘텐츠 발견에 전념
                                (Collection and Share based on the CC Protocol.)