1

Basically a teacher dropped this project in our laps the last week of the semester and I have no idea where to start. I just wanted to see if anyone has some suggestions on how to accomplish this:

This assignment will assess the student's ability to implement a simple web service. Students may use whichever technology/platform of their choosing, but the web service must satisfy the following requirements:

One service endpoint will start a timer and issue a token to the client, when the client calls back into the service with a previously issued token to a second endpoint, the elapsed time associated with that timer will be calculated and returned to the client, a third endpoint will accept a token to stop a timer and discard it, the timer's elapsed time will be returned to the client. Essentially this assignment requires a student to build a stopwatch service that starts the stopwatch, gets lap time, and gets the final time. For full credit, include a client which performs calls to each of the endpoints. The client can be a simple web page using JavaScript XMLHttpRequest objects or a helper library such as jQuery to perform the calls to the service, but the client must display the token returned by the first call, and the elapsed times returned by the second and third calls.

It is recommend that students choose a language/platform such as node.js, python, or golang as each of these languages include an http server in the standard library and all are cross-platform. It is not required to build a SOAP based web service, the solution can be as simple as a basic RESTful API.

Any help is appreciated.

  • I suggest you to start reading the [nodejs express](http://expressjs.com/) and this [stopwatch article](http://stackoverflow.com/questions/20318822/how-to-create-a-stopwatch-using-javascript) – Max Apr 26 '16 at 08:18
  • Cool, thanks for the tip – Jon Berardinelli Apr 27 '16 at 17:22

1 Answers1

0

Jon,

I believe we are in the same class and I'm in the same boat. I emailed the prof and got this response.

"Alright, if you're going to use nodejs as your platform and you've successfully installed it, you may want to take a look over this entire article to understand how nodejs serves HTTP responses to client requests:

https : //nodejs.org/en/docs/guides/anatomy-of-an-http-transaction/ Now specifically relating to the homework assignment, the subsection talking about the Echo Server shows how to create a service endpoint routed to the /echo url:

https :/ /nodejs.org/en/docs/guides/anatomy-of-an-http-transaction/#echo-server-example The line of code setting up the endpoint is the if statement:

if (request.method === 'GET' && request.url === '/echo') This is great for simple URL routing, but not so great if you wish to supply URL parameters or query string parameters! For that, you can either delve into URL parsing on your own, or take a look what is more or less becoming the de facto nodejs web application engine: expressjs. If you take a quick look at this documentation article, you might appreciate just how simple express makes setting up service endpoints in JavaScript: http: //expressjs.com/en/starter/basic-routing.html

Take a look at those articles and ask me any questions if you run into trouble. The first thing you might want to do though is attempt to run a nodejs server on your local machine to make sure it's working properly. Alternatively, you could try using a cloud-based IDE like http://cloud9.net or try a basic app runner like http://jsapp.us"

I'm struggling as well with this. Thanks for posting your question, I think the timer info will help. Now to figure out how to work with node.js.

  • Thanks Eric, I appreciate the info! I've been super busy this past week with projects and exams and haven't had much time to put into it yet. – Jon Berardinelli Apr 29 '16 at 22:21