Ejemplo n.º 1
0
    def do_POST(self):

        if 'application/json' == self.headers.get('content-type'):

            print "Content-type: application/json"

            length = int(self.headers.getheader('content-length'))
            print "Data lenght " + str(length)
            data = self.rfile.read(length)
            print "Read data : " + data
            ids = set()
            time = 0
            all = False

            for item in creator.parse(data):
                print item.keys()
                for key in item.keys():
                    if key == 'all':
                        print "Return All events..."
                        all = True
                    elif key == 'id':
                        id = item['id']
                        ids.add(id)
                        print "Add excepion list id = " + str(id)
                    if key == 'time':
                        time = item['time']
                        print "Limited time : " + str(time)
            if all or len(ids) > 0:
                jsn = creator.resp_all_events_json(ids, time)
                self.make_json(jsn)
            else:
                self.make_html()
        else:
            self.make_html()
            return
Ejemplo n.º 2
0
def post(url):
    #{13648, 13654,13664,13651,13657,13667,13670}
    json = creator.req_all_events_json({13648, 13654,13664,13651,13657,13667,13670}, time=123123)
    print "Get all events with the exception of : "
    print  json

    r = requests.post(url,None,json, auth=('user', 'pass'))

    return r