bioweb  0.09.92
C++/Python(django)/JavaScript(angularJS) framework
views.py
1 ## @file web/views.py
2 # @brief main server interface to client
3 
4 """
5 main interface to server
6 """
7 
8 import django.http
9 import json
10 import traceback
11 
12 #all modules should be imported here
13 import version
14 import version.views
15 import current
16 import current.views
17 import calcpy
18 import calcpy.views
19 
20 ## for test working server
21 def index(request):
22  """for test working server"""
23  return django.http.HttpResponse("MyApp server" )
24 
25 def ajax(request, module, function):
26  """dispatch ajax requests"""
27  try:
28  fun = getattr(getattr(globals()[str(module)], 'views'), str(function))
29  data = json.dumps( fun(request.GET) )
30  return django.http.HttpResponse(data, content_type='application/json')
31  except Exception as e:
32  return django.http.HttpResponseNotFound("myapp ajax error: " + str(traceback.format_exc()) )
33  except:
34  return django.http.HttpResponseNotFound("myapp ajax system error " )