factored http server out of main