0eac779778580372d66fecf8095757416900b2ff
[unfold.git] / engine / manifoldproxy.py
1 # this view is what the javascript talks to when it sends a query
2 # see also
3 # myslice/urls.py
4 # as well as 
5 # static/js/manifold-async.js
6
7 from django.core import serializers
8 from django.http import HttpResponse
9
10 # xxx should probably cater for
11 # format_in : how is the query encoded in POST
12 # format_out: how to serve the results
13 def api (request,format):
14     # expecting a POST
15     if request.method != 'POST':
16         print "manifoldproxy.api: unexpected method %s -- exiting"%request.method
17         return 
18     # we only support json for now
19     if format != 'json':
20         print "manifoldproxy.api: unexpected format %s -- exiting"%format
21         return
22
23     # xxx actually ask the backend here
24     hard_wired_answer = {'a':'some string','b':123}
25     return HttpResponse (serializers.serialize("json",hard_wired_answer),
26                          mimetype="application/json")