Giter VIP home page Giter VIP logo

shoe-database-api's Introduction

Shoe-database-API

A web API for interaction with a shoe database.

Installation requirements

Database

This particular implementation uses SQLite3 for database interaction. For testing, an empty database named "shoe.sqlite3" should be created with the following table schema: CREATE TABLE shoes ("id" INTEGER PRIMARY KEY AUTOINCREMENT, "description" text,"size" int, "color" text);

Directory structure

A directory named "/images" should be created in the server root directory. This will be the storage location for all user-submitted images.

Haskell requirements

This module makes use of GHC's "DeriveGeneric" and "OverloadedStrings" language pragama and thus requires the use of the GHC compiler. My own tests were conducted with GHC version 7.6.3.

Required Haskell libraries:

  • aeson (>= 0.6.2.1)
  • direct-sqlite (>= 2.3.9)
  • http-types (>= 0.8.3)
  • scotty (>= 0.6.2)

USE

The API is as follows, as per the job application requirements:

  • Server accepts POST requests via "/json". Upon successful submission, the server returns a JSON object of the form {ok: "ok", redirect: "/shoe/"}, where is the database ID of the newly submitted data. A JPEG image file submitted with this request (as a base-64-encoded string) is stored in /images/shoe-.jpg.
  • GET requests via "/shoe/" where is a number, returns an HTML response containing the submitted description, size, color and image file. Images are stored as files on the server, and tags pointing to these images are returned with the HTML response. For example "/shoe/4" returns data on the shoe with ID #4 in the database, as well as an image tag pointing to /images/shoe-4.jpg.
  • GET request via "/" or "/index" returns an HTML response containing links to all of the entries in the database.

Addtionally, raw images may be accessed via "/images/.jpg".

A sample client-side interface has also been provided in the form of the "json-form.html" file which submits user-supplied data to the server as an encoded JSON object. The server will respond to "/json-form" with the contents of this file.

shoe-database-api's People

Contributors

blgeorge avatar

Watchers

 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.