가이드 목록

Python · FastAPI

requirements.txt 로 설치하고 uvicorn 으로 실행합니다.

  1. 1main.py · requirements.txt

    python
    from fastapi import FastAPI
    app = FastAPI()
    
    @app.get("/")
    def root():
        return {"hello": "onecloud"}
    
    # requirements.txt
    # fastapi
    # uvicorn[standard]
  2. 2시작 명령

    서비스 설정 → 시작 명령에 넣거나 CLI 로 지정합니다.

    bash
    uvicorn main:app --host 0.0.0.0 --port $PORT
  3. 3배포 방법 (셋 중 하나)

    ① GitHub 연결: 프로젝트 → 서비스 추가 → GitHub 저장소 (push 하면 자동 배포) ② 이 폴더 그대로: oc up --wait (Dockerfile 이 없어도 언어를 감지해 빌드) ③ 콘솔에서 폴더 · zip 올리기: 서비스 추가 → 소스 올리기

    bash
    oc login
    oc project create my-app --link
    oc up --wait

관련 가이드