Giter Club home page Giter Club logo

a05's Introduction

a05 Human Interface

In this assignment, you will build an HTML human interface for your API. You will also document your API endpoints and consider package structure.

DO NOT CLONE THIS REPOSITORY DIRECTLY

Use the GitHub classroom link instead: https://classroom.github.com/a/PUVGxeMe

If you clone this repo directly, it will not be added to the organization as an individual repo associated with your account and you will not be able to push to it.

Instructions

Full instructions for this assignment are available at: https://comp426.johndmart.in/a/05/

Coinserver Description

This package exposes endpoints and provides a web interface to emulate random chance coin flip events in the following ways:

  1. Flip one coin - returns result of a coin flip
  2. Flip many coins - returns the results of many coin flips with a summary
  3. Guess a coin flip and - returns the result of a flip and guess match

Coinserver Installation

Run npm install inside the package root directory.

This package was buid using Node.js LTS (16.x). Other package dependency and version information can be found in package.json.

Coinserver Runtime Documentation

node server.js [options]

--port, -p	Set the port number for the server to listen on. Must be an integer
            between 1 and 65535. Defaults to 5000.

--debug, -d If set to true, creates endlpoints /app/log/access/ which returns
            a JSON access log from the database and /app/error which throws 
            an error with the message "Error test successful." Defaults to 
            false.

--log, -l   If set to false, no log files are written. Defaults to true.
            Logs are always written to database.

--help, -h	Return this message and exit.

Coinserver API Documentation

Endpoints

/app/ (GET)

Request cURL

curl http://localhost:5000/app/

Response body

{"message":"Your API works! (200)"}

Response headers

HTTP/1.1 200 OK
X-Powered-By: Express
Content-Type: application/json; charset=utf-8
Content-Length: 35
ETag: W/"23-KNmhzXgQhtEE5ovS3fuLixylNK0"
Date: Thu, 07 Apr 2022 15:07:49 GMT
Connection: keep-alive
Keep-Alive: timeout=5

/app/flip/ (GET)

Request cURL


Response body


Response headers


/app/flips/:number/ (GET)

Request cURL


Response body


Response headers


/app/flip/coin/ (GET)

Request cURL


Response body


Response headers


/app/flip/call/:guess/ (GET)

Request cURL


Response body


Response headers


/app/flip/call/ (POST)

Request cURL

curl -X POST -H 'Content-Type: application/json' -d '{"guess":"heads"}' http://localhost:5000/app/flip/call/

Response body

{"call":"heads","flip":"heads","result":"win"}

Response headers

HTTP/1.1 200 OK
X-Powered-By: Express
Content-Type: application/json; charset=utf-8
Content-Length: 46
ETag: W/"2e-U/q8iZ4JKqczXPIvtwiVRpEFlRc"
Date: Thu, 07 Apr 2022 16:30:07 GMT
Connection: keep-alive
Keep-Alive: timeout=5

/app/flip/coins/ (POST)

Request cURL

curl -X POST -H 'Content-Type: application/json' -d '{"number":"30"}' http://localhost:5000/app/flip/coins/`

Response body

{"raw":["heads","heads","heads","tails","heads","heads","tails","tails","tails","heads","heads","heads","heads","heads","heads","tails","tails","heads","heads","heads","heads","heads","heads","heads","tails","heads","tails","heads","tails","heads"],"summary":{"heads":21,"tails":9}}

Response headers

HTTP/1.1 200 OK
X-Powered-By: Express
Content-Type: application/json; charset=utf-8
Content-Length: 283
ETag: W/"11b-9dPTqGfngSPFEOq4loChIlpdSIE"
Date: Thu, 07 Apr 2022 15:23:35 GMT
Connection: keep-alive
Keep-Alive: timeout=5

/app/log/access/ (GET)

Request cURL


Response body


Response headers


/app/log/access/ (GET)

Request cURL


Response body


Response headers


/app/log/error/ (GET)

Not yet implemented

Request cURL


Response body


Response headers


/app/user/login/ (POST)

Not yet implemented

Request cURL


Response body


Response headers


/app/user/new/ (POST)

Not yet implemented

Request cURL


Response body


Response headers


/app/user/update/ (PATCH)

Not yet implemented

Request cURL


Response body


Response headers


/app/user/delete/ (DELETE)

Not yet implemented

Request cURL


Response body


Response headers


a05's People

Contributors

jdmar3 avatar sarawagi avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.