Comment on page
Add code packages to Middle to streamline your coding
Code Packages and Helper Functions
When writing your scripts for Records and Actions, you may want to import certain Python libraries or helper functions. Middle can support two import methods: code packages and upload mode.
The Code Packages section of your Middle app is useful when you want to upload Python code that can be accessed by all actions and scripts. You could upload your own Python file that has helper functions for your syncs, or you can upload helper libraries for the app you are integrating with.
To create a Code Package, click + Create next to Code Packages on the navigation bar.
Configure a code package with a name and description to explain its purpose. The Live boolean should be switched on when you want your scripts to access the package (all scripts must be re-saved to access it).
Upload a code package to reference in your scripts
A code package must be uploaded as a zip archive. The Python files within the package can be accessed by using an import statement within your action and poll sync scripts.
import requests # requests library is available for use
from index import Restart, AuthenticationChanged
from coolnewapp_middle_utils import coolnewapp_api_request