Simple Flask Server

This example shows how to start a -twisted- flask webserver inside sage, that does something with an Sage object. Read more about it in the -twisted- flask documentation.

Library

content of lib.py

from sage.all import *

def f1(a):
    a = Integer(a)
    return a / (1+a)

Server

To run it, call sage server.py ... attention, to stop it you have to kill the server via kill!

content of server.py

i'll upload a full example in a tar file.

index.html

You have to make jquery-min.js available from the jquery homepage, and mathjax for the latex formulas.

index.html

<doctype html>
<html>
<head>
<title>Simple Server Test</title>

<script type="text/javascript" src="./jquery.min.js"></script> 

</head>
<body>

This is f(4): <span id="f"></span>.
<div>
This is f(5): <span id="g"></span>.
</div>

<!-- script that does the calls needs to be placed *after* the span id=.. tags --!>
<script type = "text/javascript">
 $("#g").load("./a?name=5");
 $("#f").load("./a?name=4");
</script>
</body>
</html>

LfunctionsAndModularFormsIV/Server (last edited 2010-10-10 21:32:42 by schilly)