Refactored into flask application