Skip to content

Commit

Permalink
descriptions of code
Browse files Browse the repository at this point in the history
  • Loading branch information
jmort1021 committed Oct 29, 2024
1 parent 32cfd0c commit e931537
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions _notebooks/CSP/flask/2023-10-22-flocker_api.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,12 @@
"- **Location**: The code is in the `navigation/authenticate` directory.\n",
"- **Key Files**: Review `post.md` and `history.md` for API fetching and page formatting.\n",
"- **View in VSCode**: It's best to view these files in VSCode.\n",
"- **Inspect in Browser**: Load these files in a browser and use the inspect tool source option to verify if the code is working as expected.\n"
"- **Inspect in Browser**: Load these files in a browser and use the inspect tool source option to verify if the code is working as expected.\n",
"\n",
"### Input, Fetch and DOM\n",
"- **Input Handling**: Input is handled by an HTML form. Clicking submit triggers API requests.\n",
"- **Fetch Command**: The `fetch` command controls the request and response workflow from the API. This workflow is asynchronous, meaning the response is triggered by an event and does not wait for the response in code sequence. It waits for a promise (i.e., response event).\n",
"- **DOM Interaction**: The `document` commands interact with the page's Document Object Model (DOM). After receiving a response, the JSON data is read and written to the page in a human-readable form.\n"
]
},
{
Expand Down Expand Up @@ -462,7 +467,13 @@
"- **View in VSCode**: It's best to view these files in VSCode.\n",
"- **Testing with Postman**: Use Postman and run `main.py` in debug mode to verify code performance.\n",
"- **Request Handling**: These files handle `POST`, `GET`, `PUT`, and `DELETE` requests from the frontend.\n",
"- **RESTful Responses**: Methods provide RESTful responses containing JSON and status codes (e.g., 200, 500)."
"- **RESTful Responses**: Methods provide RESTful responses containing JSON and status codes (e.g., 200, 500).\n",
"\n",
"### PostAPI\n",
"\n",
"- **Endpoint Definition**: The `add_resource` method at the end of the class defines the `/post` endpoint.\n",
"- **CRUD Methods**: It is vital to learn the `POST`, `GET`, `PUT`, and `DELETE` methods, which correspond to Create, Read, Update, and Delete (CRUD) operations. The `_CRUD` class defines each of these methods.\n",
"- **Object Creation and Method Calls**: It is important to learn and identify object creation and method calls using the `Post` class from the backend. These calls interact with the database through SQLAlchemy's Object Relational Model (ORM)."
]
},
{
Expand Down Expand Up @@ -559,7 +570,18 @@
"- **Accessed by API Files**: These model files are accessed by the corresponding API files.\n",
"- **Initialization Functions**: Initialization functions at the bottom of these files set up test data.\n",
"- **Run Initialization**: The initialization functions are run by the `scripts/db_init.py` script.\n",
"- **CRUD Operations**: APIs and init scripts perform CRUD operations on the SQLite database `instance/volumes/user_management.db`. Use SQLite3 viewer to observe change.\n"
"- **CRUD Operations**: APIs and init scripts perform CRUD operations on the SQLite database `instance/volumes/user_management.db`. Use SQLite3 viewer to observe change.\n",
"\n",
"### Post in Model\n",
"\n",
"- **Class Definition**: `class Post` defines the model using `db.Column` ORM calls. This defines the schema of the table in the database.\n",
"- **Inheritance from `db.Model`**: The `Post` class inherits from `db.Model`, which is a base class for all models in SQLAlchemy. This inheritance provides methods for interacting with the database, such as querying and filtering.\n",
"- **CRUD Methods**: The `Post` class includes methods for Create, Read, Update, and Delete (CRUD) operations. These methods allow for the manipulation of data within the database.\n",
" - **Create**: Adds new records to the database.\n",
" - **Read**: Retrieves records from the database.\n",
" - **Update**: Modifies existing records in the database.\n",
" - **Delete**: Removes records from the database.\n",
"- **Initialization Function**: The `init_post` function at the bottom of the file initializes the table with test data. This function is useful for setting up initial data for testing and development purposes.\n"
]
},
{
Expand Down

0 comments on commit e931537

Please sign in to comment.