Refactored server module to use Flask.