My writeup for the data structures project (Enjoy!)
Collections
Here we have the unique collection with the different columns such as:
the name
description
views
the video name stored locally
thumbnail image name stored within the instances
_videoID to correspond to each video
userID to correspond who uploaded the video
genre of the video for sorting
Code to Initialize and Create Test Code Data:
In this part we create the table with the initial test data of different videos and their features.
Here’s the creation of the different videos: we utilize the upload_folder which is in the (instance/volumes/uploads) to access the different pictures. After searching for an image in that directory it’s converted to base64 and passed to the create method.
After decoding the base64 image that we passed into the create method, the new image file turns into it’s name with ID+name, Then we commit the new image file changes into the database of the thumbnail column and the videoID as the ID.
List and Dictionaries
This section goes over Object Relational Mapping (ORM) and the creation of a video object instance from a class to the database
Debugger
Here we have a list of videos seen as the video list with [vid1,vid2]
Each video has a corresponding key value and a dictionary such as the description, name, thumbnail, userID
API and JSON
Get Request
Here we query the video with the specific Video ID, when going to the corresponding integer in the URL (for example: backend/1 would corresponding to the video with ID 1)
Post Request
Here we upload the video and if the body of the response is JSON and convert all the metadata to the corresponding video object. Then we use the create method for the specific thumbnail image to the instance
Otherwise if the response isn’t JSON, so we know it’s uploading the code saves it within the VIDEO directory in the backend and we record the Video User ID
The validation above in the POST request is to make sure the JSON isn’t mepty and is formatted properly
Put Request
First it checks if the body is json, and it queries the video to the specific ID and we get the specific TYPE on the video. If the specific TYPE is registered as a 1 it’s a like and if it’s a 2 it’s considered a dislike.
We also do this with the views and we update it.
The PUT request modifies the views, likes, and dislikes
Postman
The Following is when 200 and everythign works
GET request based on the VIdeo ID for metadata
GET request of the specific video once it searches through the Video ID and finds the corresponding name in the db
POST request in Postman with the required fields filled out and uploading a video
You can see the PUT request in Postman with the corresponding VideoID to update the total amount of views.
400 errors
Here are issues that happen the body is missing in the POST request
404 error when you try and update a wrong user
Frontend
Responses
GET request shows the JSON response (just getting the specific video querying by the VIDEO ID)
POST request shows the JSON response (uploading videos)
PUT request shows the JSON response (liking the video)
In the Chrome browser, show a demo (GET) of obtaining an Array of JSON objects that are formatted into the browsers screen.
Here’s a snippet of some code that fetches for the videos based on the corresponding category into a videos list.
Then we format it into a whole grid by utilizing the rendervideos function. The function will loop through all the videos we just queried and assign a specific HREF link to the corresponding video with it’s ID.
In the Chrome browser, show a demo (POST or UPDATE) gathering and sending input and receiving a response that show update. Repeat this demo showing both success and failure.
Properly working POST request working (success)
POST request failure, I uploaded a video file that was too large for the request to handle as an image
In the In JavaScript code, show and describe code that handles success. Describe how code shows success to the user in the Chrome Browser screen.
Basically whenever you upload you are supposed to get a message on the screen that shows you success
Whenever you get an error you will get the same thing similarly but instead it shows you a failure message
Optional/Extra, Algorithm Analysis
My project Tips made a prediction on the total amount a person payed in terms of tips value.
Show algorithms and preparation of data for analysis. This includes cleaning, encoding, and one-hot encoding. (Preparation for prediction)
Cleaning the data to be a binary matrix of 1’s and 0’s, on the other hand the One Hot Encoding here will change the days which is categorical data into a binary matrix of whether or not the day was attended for tipping customers (1’s and 0’s)
Prediction
Here we simply run the prediction after training everything, which I will talk about below
Linear Regression Algorithims
We use Linear Regression here because the outcome variable which is the total amount of TIPs a person payed ia continous end value. In comparison, the Titanic which predicts categorical outcome variables such as the surviving or death probability would require Logistic Regression
I trained the X to be the different features which could all be causations for the Y variable which is the actual total amount payed in tips