I have used this in order to call python code in the server, it calls bcrypt encryption in python.

  Set password = "password"
  Set tSC = ##class(EnsLib.JavaGateway.Service).RunCommandViaCPIPE("python -c 'import bcrypt; print(bcrypt.hashpw("_$c(34)_password_$c(34)_", bcrypt.gensalt(10)))'",.pDevice,.pOutput)
  Write pOutput,!

Is it possible?: Yes
Is it a good idea: No

Proof of concept of bad idea:

Class Rest.BadExample Extends %CSP.Page

Parameter CHARSET = "utf-8";

Parameter CONTENTTYPE = "application/json";

ClassMethod OnPage() As %Status

  Set String = "[ {code:1,description:'cat'},{code:2,description:'lyon'}]"
  Write String

  Quit $$$OK


As Eduard said, you should make your own class that inherits from %CSP.REST

What I finally did was use this form of $zconvert:


I change the names of the files in order to do that, like this:

csp file:

<!DOCTYPE html>
<csp:include page="includes/libraries.csp"/>

inside the includes/libraries.csp file, rename the file as "jquery-1.11.3.min.js" instead of just use the file as "jquery.min.js" :

 <script src="jquery/jquery-1.11.3.min.js"></script> 

this in order to avoid the server to load the old file

Recently I stumbled upon the same problem, the need to use bcrypt from within caché. I did the following:

1. Install pip, the python package manager:

2. Install bcrypt with pip

sudo pip install bcrypt

3. Call bcrypt from Caché Code. The Encrypted String is pOutput

    Set password = "password"
    set tSC = ##class(EnsLib.JavaGateway.Service).RunCommandViaCPIPE("python -c 'import bcrypt; print(bcrypt.hashpw("_$c(34)_password_$c(34)_", bcrypt.gensalt()))'",.pDevice,.pOutput)
    Write pOutput,!