Refactored the code to use Flask-Pluggable Views