On May 14, 2009, at 9:27 AM, RALPH THOMAS wrote:

> Here is what I put into Sage
> -----------------------------------------------------------
> sage: from sage.server.misc import find_next_available_port
> sage: port = find_next_available_port(7777, verbose=False)
> sage: from sage.server.notebook.notebook_object import test_notebook
> sage: passwd = str(randint(1,1<<128))
> sage: nb = test_notebook(passwd, secure=False, address='localhost',  
> port=port, verbose=True) #doctest: +ELLIPSIS
> sage: import urllib, re
> sage: def get_url(url): h = urllib.urlopen(url); data = h.read();  
> h.close(); return data
> sage: sleep(1)
> sage: login_page = get_url('http://localhost:%s/simple/login? 
> username=admin&password=%s' % (port, passwd))
> sage: print login_page # random session id
> sage: session = re.match(r'.*"session": "([^"]*)"', login_page,  
> re.DOTALL).groups()[0]
> sage: sleep(0.5)
> sage: print get_url('http://localhost:%s/simple/compute?session=% 
> s&code=2*2' % (port, session))
> sage: n = factorial(10)
> sage: print get_url('http://localhost:%s/simple/compute?session=% 
> s&code=factor(%s)&timeout=0.1' % (port, session, n))
> sage: print get_url('http://localhost:%s/simple/status?session=% 
> s&cell=2' % (port, session))
> sage: _ = get_url('http://localhost:%s/simple/interrupt?session=%s'  
> % (port, session))
> sage: code = "h = open('a.txt', 'w'); h.write('test'); h.close()"
> sage: print get_url('http://localhost:%s/simple/compute?session=% 
> s&code=%s' % (port, session, urllib.quote(code)))
> sage: print get_url('http://localhost:%s/simple/file?session=% 
> s&cell=3&file=a.txt' % (port, session))
> sage: _ = get_url('http://localhost:%s/simple/logout?session=%s' %  
> (port, session))
> sage: nb.dispose()
> ---------------------------------------------------------------------- 
> ---------------------
> And all the calculations are accomplished. (2*2, factorial, text file)
> Now what do I do to get the Sage calculation into a html page?

That depends on what you're trying to do, e.g. are you serving up  
webpages using php? Another Python program? Something else?  
Basically, you can "get" the same series of url's in any programming  
language.

- Robert


--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to