Refactor API

Provide get end points
Better failing
Return data objects on post submission
Move front end scripts into js file