Edit on GitHub

#  Scripting

Sometimes, we would like to write a quick script without going through the trouble of creating a class. The addons mechanism has a shorthand that allows a module as a whole to be treated as an addon object. This lets us place event handler functions in the module scope. For instance, here is a complete script that adds a header to every request.

def request(flow):
    flow.request.headers["myheader"] = "value"
examples/addons/scripting.py