Launching the simple Sage server with user-defined functions

16 views
Skip to first unread message

Francisco Botana

unread,
Feb 22, 2011, 11:20:01 AM2/22/11
to sage-s...@googlegroups.com
Hi,

I've defined a list of Sage functions. For instance,
-----------------------------
def plus(a,b):
return a+b

def times(a,b):
return a*b

....
---------------------------
Now, I want to launch the simple server in such a way that these
functions are defined. I mean, executing

https://<IP>:<port>/simple/compute?session=<session>&code=plus(3,1)

I would like to obtain

{
"status": "done",
"files": [],
"cell_id": 1
}
___S_A_G_E___

2

Thanks in advance.

PS

For launching and remotely accessing the simple server I use
--------------------------------------------------
import time, os, random

from sage.server.misc import find_next_available_port
from sage.server.notebook.notebook_object import test_notebook
port = find_next_available_port(9000, verbose=False)
passwd = hex(random.randint(1,1<<128))

f = open('notebook_info.txt', 'w')

# create a new, empty notebook with a single user
nb = test_notebook(passwd, secure=False, address='localhost', port=port,
verbose=True)

f.write("%s\n%s\n" % (port, passwd))
f.close()

print "Press control-C to stop."

try:
# wait until a ^C
while True:
time.sleep(10)
except KeyboardInterrupt:
pass

print "Killing notebook."
nb.dispose()
--------------------------------------------


fbotana

unread,
Feb 23, 2011, 9:04:40 AM2/23/11
to sage-support
Sorry! :"> Use load.
Reply all
Reply to author
Forward
0 new messages