Migrate from django to flask