상세 컨텐츠

본문 제목

블루프린터 연습

python

by bumychoi 2026. 1. 13. 11:26

본문

from app import create_app

app = create_app()

if __name__ == "__main__":
    app.run(debug=True)

run.py

from flask import Flask
from app.blueprints.home import home_bp
from app.blueprints.admin import admin_bp

def create_app():
    app = Flask(__name__)

    app.register_blueprint(home_bp)
    app.register_blueprint(admin_bp)

    return app

__init__.py

from flask import Blueprint, render_template

home_bp = Blueprint("home", __name__)

@home_bp.route("/")
def home():
    return render_template("home.html")

home.py

from flask import Blueprint

admin_bp = Blueprint("admin", __name__, url_prefix="/admin")

@admin_bp.route("/")
def admin_home():
    return "Admin Page"

admin.py

<!DOCTYPE html>
<html>
<head>
    <title>Home</title>
</head>
<body>
    <h1>Home Page</h1>
    <p>Blueprint 연습 성공!</p>
</body>
</html>

home.html

 

'python' 카테고리의 다른 글

코딩활용능력 1급 합격  (0) 2025.08.16
벽돌깨기 오류 수정하  (0) 2025.06.02
python 텍스트 문서 음성변환  (0) 2025.05.13
똥피하기 게임  (0) 2025.04.06
계산기 tkinter 오류 해결  (0) 2025.04.04

관련글 더보기