Code for running a training server