Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Ok it is a bit late but I to look around the web a bit and here is what I found. If you have a web hosting server then you will have access to a directory called cgi-bin and public_html. In public_html keep the following file named test.html

<html><body>
<form method="get" action="./cgi-bin/test.cgi">
Input: <input type="text" name="name">
<input type="submit" value="Submit">
</form>
</body></html>

Now my cgi-bin is a subdirectory of public_html but change the path to whatever you have on your server. In cgi-bin keep a file test.cgi. The contents of test.cgi are as follows. You can import sage in the following script and use sage commands.

#!/usr/bin/python
print "Content-Type: text/plain\n\n"
import cgi
form = cgi.FieldStorage() # instantiate only once!
name = form.getfirst('name', 'empty')
ans=eval(name)
name = cgi.escape(name)
print """\
Content-Type: text/html\n
<html><body>
<p>Answer is "%s"</p>
</body></html>
""" % ans

Here the output is in html format but you can change it to make TeX. Input

image description

Output

image description