Starting from:

$25

CSE270E Assignment 11 - Chapter 6 - APIs Solved

Create a new directory called Assignment-11

Create a simple high/low guessing game and the API to support it.

 Modify the random Number app so that it uses the express static middleware and also uses the bodyparser.json middleware.

Create the following API code in app.js

Get Random Number between range

/api/v1/random/:min/:max

{"result":"YOUR RANDOM NUMBER"} or if errror

status=404

{"result":"msg"}

Get Random Number between 0 and Max

/api/v1/random/:max

{"random":"YOUR RANDOM NUMBER"} or if error

status=404

{"result":"msg"}

 Set Game Max in server. The server will let the user play high low and this call sets the maximum range for the game. /api/v1/game method: post

{"max":"number"}

{"result": "OK" } if error

status=404 result="Error"

Test Number against number in Server /api/v1/game/:number

method: get jsonOut

{"result": "HIGH" or "LOW", or "MATCH"} if bad input status=404 result="ERROR"

Create an index.html to play the game

Use very simple html. My html file is at the end of these instructions.

Create game.js that uses jquery to make calls to the API

Make sure your package.json has all the required modules

Run this server on port 3011 Make sure all your code is in git

Submit:

a clickable link to git a clickable link to your server

Video Discussion Assignment and Solution

HTML file

<!doctype html

<!--

Scott Campbell

Assignment 11

CSE 270

Winter 2019

--

<html lang="en-us"

<head

<titleGame</title

<script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"</script <script src='game.js'</script

</head

<body

<div

<h1Guessing game</h1

<h2 id='result'</h2

<form id='game'

Guess: <input type='text' id='guess'

</form

</div

<div

<h2Set guessing game range</h2

<form id='setMax'

Max: <input type='text' id='max'

<br

<input type='submit'

</form

</div

</body

</html

                           

More products