After tinkering with the unofficial notion python api for a while, I find myself constantly switching between notion and scripting environment a lot, oftentimes for the sole purpose of testing a few new lines of codes added to the entire script.
Furthermore, deployment of the service scripts to the server can be a pain, I would have to manually log onto my server, upload the file and run the script, etc. As such, I wonder if there’s a way for me to do all these unit testing, deployment in notion itself? And so this project was born.
This project allows you to create, run, and deploy python code from notion page itself by simply running a single python script in your machine.
- Run any python scripts.
- Run schedule tasks for automation purposes.
Check out the demos in the template page.
- A computer/server capable of running python scripts.
- Internet access
- Python ≥ 3.6 (Only tested version)
Based on unofficial notion python api by jamalex. Refer to his github for API references.
1. Clone this project.
2. Duplicate the control page from this Template.
3. Update local and remote config with your own.
-
Local configs
-
Rename config.json.example to config.json.
-
update notion
token
and your ownglobal config table
link.{ "token":"<Replace with your token>", "global_configs":"<Replace with your table link>" }
-
-
Remote global configs
Update your task_table and log_table link.
-
Create a new item using the template provided.
-
Add you python code here.
If you are using external modules, please install it manually.
-
Accessing global configs and outputting to notion log table.
# The handler object stores the configs handler = TaskHandler(sys.argv[1]) # To access configs using table name x = handler.configs["debug"] # Use handler print() to write to notion log table handler.print("Hello World")
-
Before you run the script, check the activate box so that the python code is written to the server.
The status will change to
Activated
.The script is not updated in realtime, therefore reactivation is needed to reflect your updated scripts.
-
Check the
Run
checkbox to run the script. Output will be written in log table ifdebug
option is set toTrue
. -
If required, check
Kill
checkbox to terminate the script.[Main]
is the parent process of all other scripts. It can neither be activated nor ran, It only can be terminated.
The script will terminate all running child processes when kill signal is issued[Main]
.