X-Git-Url: https://disinclined.org/git/?a=blobdiff_plain;f=matrix.py;fp=matrix.py;h=5ae2eba965994938ea283013d490bdf07b5a9878;hb=cf491ed085c7fb21ab8d94eb7f5c48c17504b525;hp=ea6cd9c336cc72ca745bb81ddf9a8409632d7540;hpb=b1182e5a62a5a690fc29589b2ac88ba96cd46c38;p=matrixnullspace.com.git diff --git a/matrix.py b/matrix.py index ea6cd9c..5ae2eba 100755 --- a/matrix.py +++ b/matrix.py @@ -1,4 +1,5 @@ import urlparse +import json import scipy import scipy.linalg @@ -18,10 +19,6 @@ def application(environ, start_response): if environ['REQUEST_METHOD'] == 'POST': post_data = environ['wsgi.input'].read() - output = "
"
-	#output += post_data
-	output += "
" - post_data = urlparse.parse_qsl(post_data, True, True) data_string = str(post_data[0][1]) @@ -42,25 +39,13 @@ def application(environ, start_response): # output += str(l) determinant = scipy.linalg.det(given_matrix) - output += "

" - output += "nullspace:
" - output += str(null_space) - output += "

" - output += "eigenvalues:
" - output += str(eigenvalues(given_matrix)) - output += "

" - output += "determinant:
" - output += str(determinant) -# output += "

" -# output += "eigenvalues:
" -# output += str(l1) -# output += "

" -# output += "eigenvectors:
" -# output += str(v[:,0][0]) - output += "

" + output = json.dumps({ + 'nullspace' : str(null_space), + 'eigenvalues' : str(eigenvalues(given_matrix)), + 'determinant' : str(determinant) + }) - # send results output_len = sum(len(line) for line in output) - start_response('200 OK', [('Content-type', 'text/html'), + start_response('200 OK', [('Content-type', 'application/json'), ('Content-Length', str(output_len))]) return output