Beispiel #1
0
	def get(self):
		token = request.args.get('token') 
		if token == None: # makes sure a token was entered
			return render_template("401.html"), 401

		verified = verify_auth_token(token,app.config['SECRET_KEY'])
		if verified == False:
			return render_template("401.html"), 401

		if verified == True:
			
			num = request.args.get('top')
			if num == None:
				top = 50
			else:
				top = int(num)
			_items = db.tododb.find().sort('open_times', pymongo.ASCENDING).limit(top)
			li_data = [item for item in _items]
		
			app.logger.debug("MADE IT HERE")
			dic = {}
			otimes = []	
			for item in li_data:
				otimes.append(item['open_times'])		
			dic['open_times'] = otimes
			return dic
Beispiel #2
0
    def get(self):
        token = request.args.get('token')
        if token == None:  # makes sure a token was entered
            return render_template("401.html"), 401

        verified = verify_auth_token(token, app.config['SECRET_KEY'])
        if verified == False:
            return render_template("401.html"), 401

        if verified == True:

            num = request.args.get('top')
            if num == None:
                top = 50
            else:
                top = int(num)
            _items = db.tododb.find().sort([('open_times', pymongo.ASCENDING),
                                            ('close_times', pymongo.ASCENDING)
                                            ]).limit(top)
            li_data = [item for item in _items]

            csv_string = ""
            for item in li_data:
                csv_string += item['open_times'] + ", "
                csv_string += item['close_times'] + ", "
            return csv_string
Beispiel #3
0
	def get(self):
		token = request.args.get('token')
		if token == None: # makes sure a token was entered
			return render_template("401.html"), 401

		verified = verify_auth_token(token,app.config['SECRET_KEY'])
		if verified == False:
			return render_template("401.html"), 401

		if verified == True:
			times = {}

			_items = db.tododb.find()
			_items = _items.sort([('otime',pymongo.ASCENDING), ('ctime',pymongo.ASCENDING)])
			items = [item for item in _items]

			olist = []
			for item in items:
				olist.append(item['otime'])
			times['otime'] = olist

			clist = []
			for item in items:
				clist.append(item['ctime'])
			times['ctime'] = clist

			return times
Beispiel #4
0
    def get(self):
        app.logger.debug("CHECKING RESOURCE")
        token = request.args.get('token')
        app.logger.debug("TOKEN " + str(token))

        if token == None:  # makes sure a token was entered
            app.logger.debug("TOKEN NOT FOUND ")
            return render_template("401.html"), 401

        verified = verify_auth_token(token, app.config['SECRET_KEY'])
        app.logger.debug("VERIFIED IS " + str(verified))
        if verified == False:
            return render_template("401.html"), 401

        if verified == True:
            num = request.args.get('top')
            if num == None:
                top = 50
            else:
                top = int(num)
            _items = db.tododb.find().sort([('open_times', pymongo.ASCENDING),
                                            ('close_times', pymongo.ASCENDING)
                                            ]).limit(top)
            li_data = [item for item in _items]

            app.logger.debug("DATA IS")
            app.logger.debug(li_data)

            dic = {}
            otimes = []
            ctimes = []

            for item in li_data:
                otimes.append(item['open_times'])
                ctimes.append(item['close_times'])

            app.logger.debug("OPEN IS")
            app.logger.debug(otimes)
            app.logger.debug("CLOSE IS")
            app.logger.debug(ctimes)

            dic['open_times'] = otimes
            dic['close_times'] = ctimes

            app.logger.debug("DICTIONARY")
            app.logger.debug(dic)

            return dic
Beispiel #5
0
	def get(self):
		token = request.args.get('token')
		if token == None: # makes sure a token was entered
			return render_template("401.html"), 401

		verified = verify_auth_token(token,app.config['SECRET_KEY'])
		if verified == False:
			return render_template("401.html"), 401

		if verified == True:
			_items = db.tododb.find()
			_items = _items.sort([('otime',pymongo.ASCENDING), ('ctime',pymongo.ASCENDING)])
			items = [item for item in _items]

			csv = ""
			for item in items:
				csv += item['otime'] + ", "
				csv += item['ctime'] + ", "

			return csv[:-2]
Beispiel #6
0
def load_user_from_request(request):
	token = request.args.get('token')
	if token != None:
		verified = verify_auth_token(token,app.config['SECRET_KEY'])