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.
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
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
npm run start
To stop, hit ctrl+C
or cmd+C
(keyboard interrupt)
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
orresponse.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
orresponse.text
Diagram made with Visual Paradigm Online
Footnotes
-
I believe it is compatible with most python3 versions โฉ