on
지가 선형회귀모델 프로젝트 개발 환경설정 Flask Application Factory
지가 선형회귀모델 프로젝트 개발 환경설정 Flask Application Factory
1. 청사진 파일 및 폴더 생성
- index.html -> main.html 로 수정하고 result.html을 추가해주었다.
- routes 폴더를 만들고 main.py와 result.py를 생성했다.
- 앞으로 각 라우트 마다 다른 html을 연결시키게 될 것이다.
프로젝트폴더 |_ __init__.py |_ static | |_ css | |_ img | |_ js |_ template | |_ main.html | |_ result.html |_ routes | |_ main.py | |_ result.py
2. Application Factory 설계
# __init__.py from flask import Flask def create_app(): app = Flask(__name__) from seoul_landprice_model.routes import main from seoul_landprice_model.routes import result app.register_blueprint(main.bp) app.register_blueprint(result.bp) return app if __name__ == '__main__': app = create_app() app.run(debug=True)
# routes/main.py from flask import Flask, Blueprint, render_template bp = Blueprint('main',__name__,url_prefix='/') @bp.route('/') def result(): return render_template('main.html')
반응형
from http://millennials.tistory.com/135 by ccl(A) rewrite - 2021-10-07 16:00:18