Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

flask blueprint

# example_blueprint.py
from flask import Blueprint

example_blueprint = Blueprint(
  "example_blueprint", __name__, template_folder="templates"
)


@example_blueprint.route("/test")
def test():
    return "<h1>Test</h1>"
  
# main.py
from flask import Flask
from .example_blueprint import example_blueprint

app = Flask(__name__)

app.register_blueprint(example_blueprint)
appp.run(debug=True)

# note: these two files have to be in the same folder
 
PREVIOUS NEXT
Tagged: #flask #blueprint
ADD COMMENT
Topic
Name
3+5 =