Integration of Factory method into Flask