Added error handling and took out loop from post. Other end now defines when it calls the get/post function