def home(request): """Top level url Displays :: {"path": HttpRequest.path, "host": HttpRequest.get_host(), "version": sana.api.version, "service": "REST"} """ username = request.REQUEST.get('username', 'empty') password = request.REQUEST.get('password','empty') user = authenticate(username=username, password=password) if user is not None: return HttpResponse(cjson.encode( { 'status':'SUCCESS', 'code':200, 'message': version()})) else: message = unicode('UNAUTHORIZED:Invalid credentials!') logging.warn(message) logging.debug(u'User' + username) return HttpResponse(cjson.encode({ 'status':'FAIL', 'code':401, 'message': message}))
def home(request): """Top level url Displays :: {"path": HttpRequest.path, "host": HttpRequest.get_host(), "version": mds.api.version, "service": "REST"} """ data = {'status': 'SUCCESS', 'code': 200, 'message': version()} accept = request.META.get('HTTP_ACCEPT', None) if 'application/json' in request.META.get('HTTP_ACCEPT'): return HttpResponse(cjson.encode(data)) else: return render_to_response('index.html', RequestContext(request)) '''
def home(request): """Top level url Displays :: {"path": HttpRequest.path, "host": HttpRequest.get_host(), "version": mds.api.version, "service": "REST"} """ data = { 'status':'SUCCESS', 'code':200, 'message': version() } accept = request.META.get('HTTP_ACCEPT',None) if 'application/json' in request.META.get('HTTP_ACCEPT'): return HttpResponse(cjson.encode(data)) else: return render_to_response('index.html', RequestContext(request)) '''
def home(request): """Top level url. Displays standard mds response containing following information about the system : Django version Host OS MDS version Note: If Http "Accept" header is included and set to "application/json", the returned message will be a standard MDS response as follows: { 'status':'SUCCESS', 'code':200, 'message': { 'django': django_version(), 'platform': u' '.join(platform.uname()[0:3]), 'version': version(), } } """ data = { 'status':'SUCCESS', 'code':200, 'message': { 'django': django_version(), 'platform': u' '.join(platform.uname()[0:4]), 'version': version(), }, } accept = request.META.get('HTTP_ACCEPT',None) if 'application/json' in request.META.get('HTTP_ACCEPT'): return HttpResponse(cjson.encode(data)) else: return render_to_response('index.html', RequestContext(request,data))
def home(request): """Top level url Displays :: {"status": "SUCCESS | FAIL", "code", "200|401", "message": mds.api.version() } """ username = request.REQUEST.get('username', 'empty') password = request.REQUEST.get('password','empty') user = authenticate(username=username, password=password) if user is not None: return HttpResponse(cjson.encode( { 'status':'SUCCESS', 'code':200, 'message': version()})) else: message = unicode('UNAUTHORIZED:Invalid credentials!') logging.warn(message) logging.debug(u'User' + username) return HttpResponse(cjson.encode({ 'status':'FAIL', 'code':401, 'message': message}))
def home(request): """Top level url. Displays standard mds response containing following information about the system : Django version Host OS MDS version Note: If Http "Accept" header is included and set to "application/json", the returned message will be a standard MDS response as follows: { 'status':'SUCCESS', 'code':200, 'message': { 'django': django_version(), 'platform': u' '.join(platform.uname()[0:3]), 'version': version(), } } """ data = { 'status': 'SUCCESS', 'code': 200, 'message': { 'django': django_version(), 'platform': u' '.join(platform.uname()[0:4]), 'version': version(), }, } accept = request.META.get('HTTP_ACCEPT', None) if 'application/json' in request.META.get('HTTP_ACCEPT'): return HttpResponse(cjson.encode(data)) else: return render_to_response('index.html', RequestContext(request, data))