Refactor server into several functions and print URL on starting