예제 #1
0
def delete_map():
    """
    Delete a map with its id and return the new updated metadata
    """
    _id = request.form.get("id")
    data.deleteMap(_id)
    content = json.dumps(data.getMaps())
    return Response(mimetype="application/json", status=200, response=content)
예제 #2
0
 def post(self):
     csv = self.request.files.get('csv')
     if csv:
         csv = io.BytesIO(csv[0]['body'])
     _id = self.get_argument('id') 
     # ipdb.set_trace()
     result = data.addCSVToMap(_id, csv)
     content = json.dumps(data.getMaps())
     return Response(mimetype='application/json', status=200, response=content)
예제 #3
0
def attach_file():
    '''
    Attach the file of an given _id,
    thus the data is in the multipart-form
    '''
    _id = request.form.get('id')
    csv = request.files.get('csv')
    result = data.addCSVToMap(_id, csv)
    content = json.dumps(data.getMaps())
    return Response(mimetype='application/json', status=200, response=content)
예제 #4
0
    def post(self, _id):
        info = {}
        request_data = json.loads(self.request.body)
        info['NAME'] = request_data.get('name')
        info['DESCRIPTION'] = request_data.get('description')
        data.modifyMap(request.form.get('id'), info)
        content = json.dumps(data.getMaps())

        self.set_status(200)
        self.set_header('Content-Type', 'application/json')
        self.write(content)
예제 #5
0
def change_map():
    '''
    this is the post api for modifying map
    it could modify the name and the description
    _id is a must field and 'name'/'description' are optional
    '''
    info = {}
    info['NAME'] = request.form.get('name')
    info['DESCRIPTION'] = request.form.get('description')
    data.modifyMap(request.form.get('id'), info)
    content = json.dumps(data.getMaps())
    return Response(mimetype="application/json", status=200, response=content)
예제 #6
0
def get_maps():
    content = json.dumps(data.getMaps())
    return Response(mimetype="application/json", status=200, response=content)
예제 #7
0
 def get(self, *args):
     content = json.dumps(data.getMaps())
     
     self.set_status(200)
     self.set_header('Content-Type', 'application/json')
     self.write(content)