728x90
SMALL

WEB/FastAPI 102

FastAPI(CNN 모델)와 Django(웹 구현)연동 - 다중 이미지 input

Django에서 웹을 만들고 FastAPI에서 딥러닝 모델을 돌리기 위해서 서버를 분리했다. Django에서 FastAPI API를 연결해서 데이터를 주고 받았고, 이미지를 다중으로 받아야 했기 때문에 리스트 형태로 받았다. 1) FastAPI 함수 구성 @app.post('/cnn_model') async def cnn_model(uploaded_files: List[UploadFile] = File(...)) -> JSONResponse: # 결과와 이미지를 딕셔너리에 담아 리스트에 추가 image_with_results = [] # 업로드된 파일의 객체를 바이너리로 이미지 데이터를 읽는다. for uploaded_file in uploaded_files: content = await uploaded..

WEB/FastAPI 2023.04.05

FastAPI 프로젝트 마무리(Render, Elephantsql, 배포하기) - 97

Render란?개발자는 코딩에 집중할 수 있고 인프라에 대해 걱정하지 않아도 된다. 플랫폼 서비스로 개발자가 클라우드 환경해서 애플리케이션을 구축, 실행 및 운영할 수 있도록 도와준다. 유료 버전, 무료 버전도 있으며 현재 글에서는 무료버전을 다룰 예정이다. Render 기능코드 개발 시스템 CI(Continuous Integration) / CD(Continuous Deployment)확장성과 부하분산 Render 흐름Local Git >> GitHub >> render >> 서비스 및 사용자들  비슷한 클라우드 플랫폼AWS, Azure, Google Cloudhttps://github.com/seokcode/fastapi 1. requirement.txt 만들기python 프로젝트의 의존성 정보가 담..

WEB/FastAPI 2023.02.02

FastAPI 프로젝트 git 올리기(git 명령어) - 96

git 명령어 모음Git CommandDetailsgit init비어있는 새 레파지토리를 초기화 한다. 즉, 현재 디렉터리를 git이 인식한다.(git 저장소가 생성 됨)git add .git add {파일 / 디렉터리 경로} => 디렉터리의 변경 내용의 일부만 스테이징 영역으로 보낼 때git add . => 현재 디렉터리 이하의 모든 변경 내용을 스테이징 영역으로 보낼 때git add -A =>  최상위 디렉토리 부터 모든 변경 내용을 스테이징 영역으로 보낼 때git add -p => 변경 내용을 하나씩 원하는 만큼 스테이징 영역으로 보낼 때git commit -m "{메세지}"스테이징 영역에 추가한 파일을 commit을 통해 트랜잭션을 완료한다.git branch -M mainmain 브랜치 생성gi..

WEB/FastAPI 2023.02.01

FastAPI 프로젝트 진행(비밀번호 변경, 라우터 추가) - 95

프로젝트 디렉터리 구조 fastapi todoapp main.py database.py models.py todos.db templates static routers todo css js home.html add-todo.html edit-todo.html login.html register.html layout.html navbar.html edit-user-password.html base.css bootstrap.css bootstrap.js jquery-slim.js popper.js auth.py todos.py users.py templates 하위에 edit-user-password.html 생성 routers 하위에 users.py 생성 1. users.py 기본 세팅 import sys ..

WEB/FastAPI 2023.01.31

FastAPI 프로젝트 진행(로그아웃 기능 구현) - 92

1. auth.py 새로운 API 생성 @router.get("/logout") async def logout(request: Request): msg = "logout Successful" response = templates.TemplateResponse("login.html", {"request":request, "msg":msg}) response.delete_cookie(key="access_token") return response response를 직접 return delete_cookie로 현재 cookie에 저장된 JWT를 삭제 2. 웹 확인 API 호출을 통해서 알럿과 함께 cookie상의 데이터가 없어진 것을 확인할 수 있다. 3. navbar.html에 로그아웃 버튼 추가 Todo ..

WEB/FastAPI 2023.01.29
728x90
SMALL