From VSCode using SQLite3 Editor, show your unique collection/table in database, display rows and columns in the table of the SQLite database.:

SQL

Each row represents a different user’s credentials and identity information, stored securely to manage authentication and identification within an associated system or application. The hash format includes the algorithm (pbkdf2:sha256), the number of iterations (260000), and the hash value itself.

From VSCode model, show your unique code that was created to initialize table and create test data:

table-thing

UserID is defined as an integer column in the database. It is marked as a foreign key that references ‘users.id’, which means it links to the id column of the users table. This establishes a direct database relationship between the Post and a User model, ensuring that each post is associated with a specific user.

In VSCode using Debugger, show a list as extracted from database as Python objects:

python-object-list

A database query retrieves a list of houses, which are then processed and potentially filtered based on certain conditions. This shows usage of SQLAlchemy for database interactions in a Flask application, where database rows are fetched as objects

In VSCode use Debugger and list, show two distinct example examples of dictionaries, show Keys/Values using debugger:

keys-values

These dictionaries are shown in the debugger under the section labeled “Locals,” highlighting how each dictionary is structured with keys corresponding to specific attributes and values holding data related to those attributes. For example a key is country and the vealue is France

In VSCode, show Python API code definition for request and response using PUT, POST, DELETE methods. Discuss algorithmic condition used to direct request to appropriate Python method based on request method:

Screenshot 2024-04-23 151211

Post,delete

  • POST Method (Create): The post method reads data from the JSON body of the incoming request. It performs validation checks on the user’s name and ID, ensuring they are present and sufficiently long, then looks up additional data such as password and date of birth. After validation, a new user object is instantiated and presumably saved to the database.

  • PUT Method (Update): The put method also retrieves data from the JSON body, which includes various user attributes such as name, UID, password, and additional arbitrary data like scores and cards. It iterates over all users, updating the attributes of the user identified by a UID match. The method seems to be protected by a token requirement, ensuring only authenticated users can make updates.

  • DELETE Method (Delete): Similar to the PUT method, the delete method uses an authentication token to verify the user’s identity before proceeding to delete the user. It decodes the JWT token to find the current user’s UID, and deletes the user record that matches this UID, thus preventing unauthorized users from deleting records.

In VSCode, show algorithmic conditions used to validate data on a POST condition:

Screenshot 2024-04-23 153659

The token_required decorator in the Python code ensures security for API endpoints by:

  • Validating JWTs: Checks if the JWT in the request’s cookies is present and valid; if not, returns a 401 Unauthorized error.

  • User Verification: Confirms the token’s user ID matches a valid user in the database; invalid users result in a 401 error.

  • Role-Based Access: Enforces that the user’s role matches required roles for access, otherwise returns a 403 Forbidden error.

  • Error Handling: Catches any exceptions, issuing a 500 Internal Server Error for unexpected issues.

In Postman, show URL request and Body requirements for GET, POST, or UPDATE methods:

Screenshot 2024-04-18 153423

  • URL: http://127.0.0.1:8762/api/users/authenticate - This is the endpoint to which the request is being sent. The local development server address (127.0.0.1 is the localhost IP) and is for a user authentication service.

  • Body Type: JSON - The body of the request is formatted as JSON.

  • Data:

    • “uid”: “toby” - This is a user identifier or username.
    • “password”: “123toby” - This represents the password associated with the user account.

In Postman, show the JSON response data for 200 success conditions on GET, POST, or UPDATE methods:

Screenshot 2024-04-23 152036

The JSON data in the response contains information about users. Each user is represented as a JSON object within an array, indicating multiple user records were returned.

In Postman, show the JSON response for error for 400 when missing body on a POST request:

Screenshot 2024-04-23 152522

The JSON response contains a message key with the value “Invalid user id or password”, signifying that either the username or the password provided does not match the records, or was not provided in the correct format.

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 in the Chrome browser.

Screenshot 2024-04-18 154400

  • General: Shows general information about the selected request.

  • Request URL: Indicates the URL to which the POST request was sent (http://127.0.0.1:6221/login/).

  • Request Method: Shows that the method of the request was POST.

  • Status Code: Displays 200 OK which means the request was successful and the server responded appropriately.

Screenshot 2024-04-18 154413

This displays a 401 unauthorized error showing the failure. I did this by entering the wrong things for the login.

Show and describe code that handles failure. Describe how the code shows failure to the user in the Chrome Browser screen in JavaScript code.

Screenshot 2024-04-23 153659

  • Missing Token: If no JWT is found in the request’s cookies, it returns a 401 Unauthorized error with a message stating “Authentication Token is missing!”.

  • Invalid Token: If the JWT fails validation (e.g., tampering, expiration), it sends a 401 Unauthorized error with “Invalid Authentication token”.

  • Insufficient Permissions: If the authenticated user lacks required roles, the system sends a 403 Forbidden error with “Insufficient permissions”.

  • Unhandled Exceptions: For any other errors (like internal server errors), it returns a 500 Internal Server Error with “Something went wrong”.

Linear regression is a way to predict a value based on the relationship between two variables. It involves drawing a straight line through data points on a graph to best represent how one variable affects another. For instance, it can help predict sales based on advertising spend. The line’s position and slope are calculated to show the relationship as accurately as possible. The difference between Linear and Logistical regression is that Linear reggression is numerical values, Logistic is predicting the probability of an outcome, event, or observation. Logistic is categorical values like male or female and linear is numerical like price. Linear gives an output numerically and logistical regression does a probability, like titanic model.

A decision tree is a model used to make decisions by mapping out different choices and their possible outcomes, much like a flowchart. It starts with a question or decision at the top and branches out into possible responses or further questions, leading to final decisions or actions. This method is commonly used in both business for strategic planning and in data science for predicting outcomes based on input data.