Ejemplo n.º 1
0
        return jsonify("Delete successful")
 
 
@app.route("/api/manage-user-modify-entry",methods=['POST','GET'])
@token_required
def manageUserModify():
    user=request.get_json() #get modifying user's details
    #connection with mongo sending the details of modified entry
    try:
        user_wrapper: UserWrapper = MongoDB.updateUser(user)
    except TypeError as type_err: #Checking for errors
        return str(type_err), 422
    except ValueError as value_err:
        return str(value_err), 422
    except:
        return "Bad error", 500
    else:
        if user_wrapper.user is None:
            return "Something is wrong with the database", 500
        if type(user_wrapper.user) is dict and not user_wrapper.operationDone and not user_wrapper.found:
            return "Couldn't update user entry", 500
        return jsonify("Save successful")
 
 
if __name__ == '__main__':
    print("Resetting database data...")
    MongoDB.dropDatabases()
    print("Initializing database data...")
    MongoDB.createMockDatabase()
    app.debug = True
    app.run(host="0.0.0.0")
Ejemplo n.º 2
0
from MongoDatabase.MongoDB import MongoDB

mongo = MongoDB()

mongo.dropDatabases()

mongo.createMockDatabase()