Instead of duplicating flask code like we are doing here, it might be worth to check alternatives : https://github.com/sampsyo/confuse