4

I have a code written in Mathematica. What I am trying to do is to write a wrapper (say using Python) that will take user input for the Mathematica code, run the code, and create output.

I do not want the Mathematica code to be seen by the user while it is being run.

The idea is that user just clicks on an executable, Mathematica code runs in the background, asks user for some input parameters, and generates output.

How can I do that? Which utilities can I use?

Kuba
  • 136,707
  • 13
  • 279
  • 740
  • Maybe using python you can run Mathematica from command line ( link ). Have you tried that? Also some functionality is described here – K.J. Nov 29 '17 at 19:44
  • Create a Wolfram Cloud based API. Very easy to set up and call. – ktm Nov 29 '17 at 20:32
  • @K.J.

    I tried running the code from command line.

    1. If I do

    C:\path\to\code\code.m This opens a Mathematica session and runs the code. But the code is visible to the user. This is not desired.

    1. I tried

    C:\path\to\code\wolframscript -code code.m This throws an error: " 'wolframscript' is not recognized as an internal or external command, operable program or batch file."

    – CuriousCoder Nov 29 '17 at 20:34
  • @user6014

    Cloud based API is not a desired way to go for me. I am assuming that the code would reside in the cloud in this approach. The code needs to reside on a local machine for my purpose.

    – CuriousCoder Nov 29 '17 at 20:41
  • You can set up a local HTTP server in the way that I outline here. It would be like working against the cloud, except your API would be run locally. – C. E. Nov 29 '17 at 21:11
  • @C.E. The code will potentially be distributed to other users who may use it on standalone computers. I don't expect them to be on network. My only expectation for them is to click on an executable and run the code. Currently they can open a Mathematica session and run the code, however they can see the code. I would like to keep the same ease of use but hide the code. – CuriousCoder Nov 29 '17 at 21:25
  • Sure, that's what you can do with the approach I outline in that answer. You'd bundle the Java code and the Wolfram Language scripts with your Python application, upon startup your Python application would launch one of the Wolfram Language scripts, which would then start the HTTP server and let you communicate with your Wolfram Language backend in a RESTful manner. – C. E. Nov 29 '17 at 21:29
  • Have you considered creating a CDF with Mathematica (link)? – Edmund Nov 30 '17 at 03:09

0 Answers0