5
$\begingroup$

I have written a small program that accepts a string as input and returns a List of graphical images as output. A simple example is shown below.

How best to deploy this on a machine without a Mathematica license? I think CDF is not a option because the code accepts an arbitrary string as input. My experimentation with deploying on the cloud and MailReceiverFunction has led only to errors and scrambled output. I am open to any suggestions.

Here is a trivial example

demo[in_String] := Module[{pic},
  pic = xxxx;
  Table[pic, {StringLength[in]}]
  ]

Where the xxxx is a Graphics image. In Mathematica, it looks like this:

code that works on the desktop

The code works as intended on the desktop, so

demo["test"]

returns

a List of Graphics

And integrating it with FormPage works as intended as well, so long as I stay on the local machine.

FormPage["inString" -> String, demo[#inString] &]

a working Form-based interface

My goal is to be able to access this from another machine, so I deploy to the web, with

CloudDeploy[FormPage["inString" -> String, demo[#inString] &]]

But this doesn't work. Instead of returning a list of Graphics, I get

{ " class="img-responsive"/> " class="img-responsive"/> " class="img-responsive"/>

And with slightly more elaborate examples, pages of text that look like some kind of ASCII-based encoding of the graphics images. In any case, certainly not the graphics themselves.

Help?

$\endgroup$
  • $\begingroup$ As I understand the question you have a node with a Mathematica license (perhaps in the cloud), a node without a Mathematica license, and from the node without a license you want (either by a browser or email) to remotely execute code on the node with the license. Correct? $\endgroup$ – Christopher Haydock Dec 26 '15 at 21:31
  • $\begingroup$ @ChristopherHaydock I have code running on a desktop machine that has a license; the same code may be deployable to the cloud, I'm not sure. I would like to submit input (a string) to the software from a machine that doesn't have a Mathematica license, and to receive the output on that machine. Could be via a webpage, e-mail, or other mechanism. Does that help? $\endgroup$ – Michael Stern Dec 26 '15 at 22:13
  • $\begingroup$ The APIFunction and CloudDeploy feature might be what you are looking for see the example in the documentation page $\endgroup$ – Sascha Dec 27 '15 at 0:05
  • $\begingroup$ The approach @Sascha mentions, or FormFunction or FormPage, can run your code in the cloud on the Wolfram Development Platform, which can be accessed from any browser. If you want to do the same thing, but with the code running on your own licensed machine, then you could set up a private cloud on this machine. $\endgroup$ – Christopher Haydock Dec 27 '15 at 0:34
  • $\begingroup$ @ChristopherHaydock have tried several of these approaches, including CloudDeploy@FormPage, which would seem to do exactly what I want, but instead of outputting a list of graphics, it outputs long strings of random characters with occasional tags like class="img-responsive"/> $\endgroup$ – Michael Stern Dec 27 '15 at 3:57
5
$\begingroup$

In the simplest case the FormPage function would return a graphic:

CloudDeploy[
   FormPage["inString" -> "String",
      GraphicsGrid[{
         Table[
            Image[
               Graphics[{Disk[{0,0}, Sqrt[2]], Red, Disk[]}], ImageSize -> 32],
            {StringLength[#inString]}
         ]
       }] &
   ],
   FileNameJoin[{$CloudRootDirectory,"FormPageDemo"}]]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.