Now that we’ve connected our app to our local machine, we can write a function to return data to be plotted in our dashboard.

In your script, define a function called get_marketing_data, and decorate it with @anvil.server.callable to make it available inside your Anvil app. We’ll start by making it return some test data:

def get_marketing_data():
    # access data on your local machine and return as a Python list
    return [{'strategy':'Strategy A', 'count':200}, 
            {'strategy':'Strategy B', 'count':185}, 
            {'strategy':'Strategy C', 'count':175}]

Stop and re-run your script to apply this change.

If you have local PostgreSQL database you wish to connect to, you can connect to it in this function in the same way that we did in Step 1.