add flask restful support & refactoring