I might be missing something, but can you show an example of calling the API from javascript?
You seem to be writing it in python and then calling it from within python in the example.
You seem to be writing it in python and then calling it from within python in the example.