Skip to content

Evaluation: Blueprint Library

Ethan-Strominger edited this page Nov 8, 2021 · 1 revision

Blueprint is a specific library.

A big advantage of blueprint lets you treat the frontend and backend together as a unit. You can also put the routes in the blueprint as wel.

Since we are using React and decided to centralize all routes in one file, the Blueprint library will not be useful. Example of a blueprint taken from a Real Python tutorial:

from flask import Blueprint, render_template
from ecommerce.models import Product

products_bp = Blueprint('products_bp', __name__,
    template_folder='templates',
    static_folder='static', static_url_path='assets')

@products_bp.route('/')
def list():
    products = Product.query.all()
    return render_template('products/list.html', products=products)

@products_bp.route('/view/<int:product_id>')
def view(product_id):
    product = Product.query.get(product_id)
    return render_template('products/view.html', product=product)
Clone this wiki locally