I want to add a
app = Flask(__name__)
from server.api import api
assert False, 'this is never printed'
api = Blueprint('api', __name__)
Flask doesn't see what happens to the blueprint after it is registered. All setup, such as registering before request functions, must happen before registering the blueprint. Typically, things are registered near the blueprint's definition or in it's package, not after a semantically unrelated import.