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)์ด ๊ฐ์์๋ ์๋จ.
๋ ์ค ํ๋๋ฅผ ๋ณ๊ฒฝํ๋ฉด ์ ์์ ์ผ๋ก ์๋
'TIL > ETC' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
React ๋ฌธ์์ด ํํ์ htmlํ๊ทธ ๋ ๋๋ง ํ๊ธฐ (2) | 2021.03.12 |
---|---|
์๋ฐ์คํฌ๋ฆฝํธ ํฐ๋ฐ์ดํ ์ ๊ฑฐ - replace (0) | 2021.03.12 |
Flask ๋๋ฒ๊ทธ ๋ชจ๋๋ก ์คํ (0) | 2021.02.23 |
Flask run ์๋ํ ์ค์ (0) | 2021.01.27 |
OSError: [Errno 48] Address already in use (0) | 2021.01.24 |