Separated consuming and processing logic and added Flask app for api