refactor templates data gen and http apart.