Refactor HTTP server to use environment