혼자 따로 해본 개와 고양이 분류 image classification
https://colab.research.google.com/drive/1brVI5WYYChr1GYxQgyBTe5To_5iqQVQn#scrollTo=y64ONt4efn4n
Google Colaboratory Notebook
Run, share, and edit Python notebooks
colab.research.google.com
blueprint
templates/main_views.py
from flask import Blueprint
bp = Blueprint('main', __name__, url_prefix='/')
@bp.route('/hello')
def hello_pybo():
return 'Hello, Pybo!'
@bp.route('/')
def index():
return 'Pybo index'
Blueprint를 import 해온 후 bp라는 변수에 Blueprint 객체를 만들어주는데 bp 객체 생성시 사용된 __name__은 모듈명인 "main_views"가 인수로 전달된다. 첫번째 인수로 전달한 "main"은 블루프린트의 "별칭"이다 이 별칭은 나중에 자주 사용할 url_for 함수에서 사용된다. url_prefix는 라우팅 함수의 애너테이션 URL 앞에 기본으로 붙일 접두어 URL을 의미한다.
__init__.py
from flask import Flask
def create_app():
app = Flask(__name__)
from .templates import main_views
app.register_blueprint(main_views.bp)
return app
main_views.py 파일에 생성한 블루프린트 객체 bp를 app.register_blueprint(main_views.bp)로 등록했다.
이 상태로 localhost:5000에 접속하면 'Pybo Index' 가출력되고 localhost:5000/hello 에 접속하면 'hello Pybo' 가 출력됨
'회고록(TIL&WIL)' 카테고리의 다른 글
TIL 2022.05.19 머신러닝 팀프로젝트(object detection) - 2 (video 태그, 동영상 업로드(미리보기), glob, os.path) (0) | 2022.05.19 |
---|---|
TIL 2022.05.18 머신러닝 팀프로젝트(opject detection) - 1 (S.A) (0) | 2022.05.19 |
TIL 2022.05.16 머신러닝 정리 (0) | 2022.05.16 |
TIL 2022.05.13 git 정리, 머신러닝 (0) | 2022.05.13 |
TIL 2022.05.11 클론코딩 팀프로젝트(BE) - 6 (프로젝트 종료, KPT, 소감, 피드백) (1) | 2022.05.11 |