Git Product home page Git Product logo

cs361-microservice's Introduction

Gradebook CSV Microservice

Gradebook API for getting and making csv files. Contains a demo on how to send requests and recieve data, specifically for the Python (3.10)1 requests library.

Gradebook API Contract

Currently API will have to run locally for the server and have a gradebook folder with csv files. The csv file will contain a header "date,gpa" and the next lines will contain the date and gpa data. There is no enforcement on the types/format of the date and gpa values.

date,gpa
yyyy-mm-dd,float

Setup

Before you run the API, run source .env to fill env variables:

PORT = ...
API_KEY = ...
GRADE_FOLDER = ...

NOTE: api keys are not currently used or authenticated

Install needed python libraries:

pip install -r requirements.txt

Run

npm run start

To stop, hit ctrl+C or cmd+C (keyboard interrupt)

Requests & Responses

NOTE: Anything in {} is meant to be replaced with the corresponding value, :name are parameters

baseURL = "http://localhost:{PORT}"

  • GET /files

    • Returns string of csv gradebook files separated by a comma
    • Python example:
      • response = requests.get(baseURL + /files)
      • files = response.text
  • GET /files/:file

    • Returns contents of specified csv file as a string
    • Python example:
      • response = requests.get(baseURL + "/files/{file}")
      • csv_string = response.text
  • POST /files/:file/new

    • Create new csv file with specified grades
    • Python example:
      • data = {"header": "data,gpa\n", "grades": "yyyy-mm-dd,gpa\n"}
      • response = requests.post(baseURL + "/files/{file}/new", json = data)
      • response is a status code and simple message (OK=200, ERR=500)
      • can access response via response.status_code or response.text
  • POST /files/:file/add

    • Append new grades to an existing gradebook
    • Python example:
      • data = {"grades": "yyyy-mm-dd,gpa\n"}
      • response = requests.post(baseURL + "/files/{file}/add", json = data)
      • response is a status code and simple message (OK=200, ERR=500)
      • can access response via response.status_code or response.text

UML Sequence Diagram

Diagram made with Visual Paradigm Online

UML Sequence Diagram of client-server gradebook api

Footnotes

  1. I believe it is compatible with most python3 versions โ†ฉ

cs361-microservice's People

Contributors

fam-cs 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.