def mongo_add_cars(): data = request.json obj1 = MongoAPI(data) obj1.populate() response = obj1.read() return Response(response=json.dumps(response), status=200, mimetype='application/json')
def mongo_remove(): data = request.json if data == None or data == {} or 'document' not in data: return Response(response=json.dumps({'Error': 'Invalid data request format'}), status=400, mimetype='application/json') obj1 = MongoAPI(data) response = obj1.delete() return Response(response=json.dumps(response), status=200, mimetype='application/json')
def mongo_read(): data = request.json if data is None or data == {}: return Response(response=json.dumps({'Error': 'Invalid data request format'}), status=400, mimetype='application/json') obj1 = MongoAPI(data) response = obj1.read() return Response(response=json.dumps(response), status=200, mimetype='application/json')
def mongo_write(): data = request.json if data == None or data == {} or 'document' not in data: return Response(response=json.dumps({'Error': 'Invalid data request format'}), status=400, mimetype='application/json') if 'email' in data['document'].keys(): if Validators.validateEmail(data['document']['email']): pass else: return Response(response=json.dumps({'Error': 'Invalid data request format'}), status=400, mimetype='application/json') obj1 = MongoAPI(data) response = obj1.write() return Response(response=json.dumps(response), status=200, mimetype='application/json')
# ====================================================================================================================== # globals # ====================================================================================================================== f_updated = False size_limit = 50 running = False time_spans = ('hour', 'day', 'week', 'month', 'year', 'all') current_version = 4.3 debugging = False logging.basicConfig(filename="RedditTopOfBot.log", format='%(asctime)-15s %(message)s') mapi = MongoAPI(db_name, db_username, db_password) # ====================================================================================================================== # Utils # ====================================================================================================================== def poc(string): """ Debugging Aid, Prints a string to the cli if the GLOBAL VARIABLE 'debugging' is true :param string: string to print :return: """ if debugging: