GithubHelp home page GithubHelp logo

diamond-api's Introduction

Semantic Web and Linked Data - Exercise 5

Diamond API

In this exercise we will build a HTTP API for keeping stock of our diamonds.

Exercises

  1. In diamond.js, write code to create a sqlite database, with a single table that has the following fields (Explanations for all fields except id are available in the file prices-of-diamonds.html. id should be an auto-incrementing primary key.):
  • id
  • carat
  • cut
  • color
  • clarity
  • depth
  • table
  • price
  • x
  • y
  • z
  1. Write a function to load the contents of prices-of-diamonds into the database.

  2. Add four methods to the express app in diamond.js to:

  • GET a diamond by its id.
  • POST a new diamond, which will respond with the new id of the diamond.
  • PUT a new diamond at a given id.
  • DELETE a diamond by its id.
  1. Test the use of the API using curl.

Advanced exercises

  1. Create a single HTML file to interact with the API using AJAX calls.

Note

  • See the sqlite3 npm page here for an example of using a sqlite database in node.

  • See the node-sqlite3 GitHub page here for more information on using sqlite in node.

  • See the Express documentation here for example of using GET, POST, PUT and DELETE.

  • See this blog post for example of using Curl to test an API.

diamond-api's People

Contributors

ianmcloughlin avatar

Watchers

James Cloos avatar James Ngondo 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.