TIL/ETC
AttributeError: module 'calendar' has no attribute 'bp'
inistory
2021. 1. 25. 03:05
blueprint ๋ฅผ ์ฌ์ฉํ์ฌ calendar.py ํ์ผ์ app.py์ import ํ๋ ๊ณผ์ ์์ ์๋ฌ ๋ฐ์
calendar.py ํ์ผ ์ํ
from flask import Blueprint
bp = Blueprint("calendar", __name__), url_prefix="/calendar")
@bp.route('/calendar',methods=['GET','POST'])
def calendar():
return render_template("calendar.html")
app.py ์ํ
with app.app_context():
import calendar #calendar.py๋ฅผ ์ํฌํธ
app.register_blueprint(calendar.bp)
ํด๊ฒฐ
bp ์ด๋ฆ(Blueprint("calendar"))๊ณผ ํ์ด์ฌํ์ผ ์ด๋ฆ(calendar.py)์ด ๊ฐ์์๋ ์๋จ.
๋ ์ค ํ๋๋ฅผ ๋ณ๊ฒฝํ๋ฉด ์ ์์ ์ผ๋ก ์๋