목록flask (2)
개발 일지
flask-sqlalchemy를 처음 사용할 당시 ORM 자체를 처음 사용해서인지 relationship이란 개념을 이해하기가 어려웠다. 해당 게시글은 relationship을 이해하기 위해 공식 docs의 일부분을 간단히 번역한 글이다. 공식 문서 https://flask-sqlalchemy.palletsprojects.com/en/2.x/models/ Declaring Models — Flask-SQLAlchemy Documentation (2.x) Declaring Models Generally Flask-SQLAlchemy behaves like a properly configured declarative base from the declarative extension. As such we rec..
blueprint flask 내의 라우드(route)함수들을 세분화하여 구조적으로 관리하기 위해 사용하는 방법 블루프린트 객체를 생성해 라우트함수들을 구현하고 해당 블루프린트를 flask app에 등록하여 사용한다 hello.py 1 2 3 4 5 6 7 8 9 10 11 12 from flask import Blueprint hello_blue = Blueprint('main', __name__, url_prefix='/') @hello_blue.route('/') def hello_world(): return 'Hello, World!' @hello_blue.route('/blueprint') def hello_python(): return 'Hello, Blueprint!' cs app.py 1 2..