refactor

separated the server and request code
added json example