Anvil’s Server Modules are a full server-side Python environment. Server Modules cannot be edited or seen by the user, so we can trust them to do what we tell them. This is why we’ll use a Server Module to access the Data Table we just created.
Create a Server Module by clicking the ‘+’ next to Server Code in the App Browser. You’ll see some code with a yellow background:
We’ll write a server function that requests data from the ‘Revenue’ data table we just created. We’ll use the
search() method to do this.
Add this function to your Server Module:
@anvil.server.callable def get_revenue(): return app_tables.revenue.search()
@anvil.server.callable decorator allows us to call this function from client code.
That means we have a function we can call from the browser to securely access data from the ‘Revenue’ Data Table. We’ll plot this data in the next step.