예제 #1
0
def home(request):
    db = get_db()

    obj = EvgTest()
    obj['name'] = 'roy'
    obj.ip_addr = '127.0.0.1'
    obj.save()

    documents = db.EvgTest.find()
    return HttpResponse(json.dumps(documents, cls=SdccJsonEncoder))
예제 #2
0
def _post(request):
    db = get_db()
    obj = db.EvgTest()
    obj['name'] = str(request.POST.get('name'))
    obj['ip_addr'] = str(request.POST.get('ip_addr'))

    obj1 = {
        'name' : "SecurityDAM",
        'ip_addr' : "192.168.0.1"
    }
    db.EvgTests.save(obj1)
    try:
        obj.save()
    except:
        import traceback
        print traceback.format_exc()
        return HttpResponse(status=401)
    return HttpResponse(json.dumps(obj, cls=SdccJsonEncoder))