sending page requests?

23 views
Skip to first unread message

Lonnie Cumberland

unread,
Apr 28, 2020, 2:07:05 PM4/28/20
to mathic...@googlegroups.com
Hello All,

I am working a bit with Mathics and want to incorporate it as a backed serve for a project that I am working on now.

With that in mind, I can startup the server "mathicsserver" and then go to "http://localhost:8000" after which I am presented with a nice workspace.

What I would like to be able to do is to send it an initial equation or sequence that it will run.

I can think of 2 cases that I would be interested in working out:

1. Send an equation string and get back a result via JSON or perhaps XML that I can then embed as output to the user.

or

2. Send an equation string and have it run that equation string on the initial call that is evaluated and then the user can continue to do other things in the workspace.

Is there anything like this built into the current Mathics system?

If not, then how hard would it be to add?

Cheers,
Lonnie

Rocky Bernstein

unread,
Nov 7, 2020, 5:15:14 AM11/7/20
to mathics-users
In short, making this easier to do is on the todo list. Because this is an open-source program, anything is doable if you put in the work to do it.

Below I'll describe various mechanisms that exist now that you might experiement with. 

From the outside the Django interface, one gross way to send a query to the UI is to encode the query into the URL. 
For example if you have the Mathics Django server running on http://localhost:8000

http://localhost:8000/#cXVlcmllcz01 will run the expression 5 and http://localhost:8000/#cXVlcmllcz01JnF1ZXJpZXM9Ng== will run the expressions 5 and then run 6. 


To get JSON output back this is done in Python by running some sort of Evaluation() command specifiying that you want "XML" output. For example the part of the Django server that does this  is https://github.com/mathics/Mathics/blob/master/mathics/web/models.py#L20-L27

What woud be better is to work with some sort of Jupyter interface which no doubt would do this. The two projects that work with Jupyter are iwolfram and and IMathics. Right now both need fixing up. 
Reply all
Reply to author
Forward
0 new messages