FastAPI - Swagger is a Python web framework used for building APIs. The sections to notice when using swagger are:
- Request body
- Responses
- Server response
- Responses
Request body is where you will input the data that you want to be processed
Responses is where you will get the response to the data you just inputted. Two sections to pay attention to are:
- Server response: this is the live response from server with the data you inputted
- Responses: this shows the possible responses and associated codes
200: Successful Response
The endpoing functioned properly with the input supplied
422: Validation Error
The request cannot be fulfilled due to incorrect input
500: Internal Server Error
The server encountered an unexpected condition that prevented it from fulfilling the request
Buttons that are commonly used are:
- Try it out: allows access to inputting data
- Execute: runs the endpoint based on the data supplied in Request body
- Reset: returns the Request body to default position
Function: description of function.
Image of the swagger screenshot.
Request body:
input to be inserted into the Request body text box.
Image of the swagger screenshot after execute is clicked.
Request body:
{
"username": "string",
"first_name": "string",
"last_name": "string",
"password": "string",
"email": "string",
"grad_class": "string"
}
Request body: id of user you want to see
Request body: N/A
Request body:
{
"first_name": "string",
"last_name": "string",
"email": "string",
"grad_class": "string"
}
Request body:
id of user you want to delete
Request body:
username: enter username
password: enter password
Request body: N/A
Request body: N/A
Request body:
{
"content": "string",
"date_posted": "2024-02-09"
}
Request body:
id of post you want to see
Request body: N/A
Request body: N/A
Request body:
user_id: id of the user you want to get all posts for
Request body:
post_id: the id of the post you want to change
{
"content": "string",
"date_posted": "2024-02-09"
}
Request body:
post_id: id of post you want to delete
This is the LifeLink Web App. The pages are classified into different name:
- Home page before sign in
- Log in
- Sign up
- Home page after sign in
- My profile
- List of users
- Specific user
- Update user
This page is the first page an unlogged in user will get to, it gives a mock home page with navigation buttons to sign up, login, as well as see who is registered.
This is the log in page, from here you can enter your username and password and upon clicking Login, you will be logged in and redirected to the "Home page after sign in". Your password is automatically hidden for security purpose, but there is also the option to show your password.
This is the sign up page, here you will enter your Username, Password, First name, Last name, Email, and Graduating Class. Like with the log in page you have the option to show you password. Once you click Sign up, you will be registered and directed to the "Home page after sign in".
Here is your Home page, this version of "after sign in" is different than "before sign in" in which you will now be able to view the posts of your other Hack Reactor graduates. On each post under "LifeLink Feed" you will be able to see their name, the date is was posted, and the contents of their post. Your navbar has also changed, no longer showing login/sign up, and now showing List of Users, My Profile, Update Profile, and Logout. Below the navbar you see a text box with "What's new?" that is where you input the text for your post. The submit button on the right processes and submits your post and updates it to the LifeLink Feed.
This is your profile, it will show the information you entered upon sign up as well as filter out only the posts you have published to the Lifelink Feed. You also have the option to post to the feed from here with the same method as you do in "Home page after sign in". On the right side of the page you have the ability to delete and update your profile as well as edit and delete an individual post. If you choose to click Delete Account, you will be asked to confirm deletion of not only your account, but your posts as well. The Update Profile button will bring you to the "Update Profile" page, the edit button for editting a post will behave similarily to the update profile button.
This page displays all users that are currently registered in the LifeLink Database. From here you can click on the user's name to view their specific profile.
Once you click on a users name (either from the "List of users" or "Home page after sign in" pages) it will bring you here. It is very much like the "My profile" page except it displays the information and posts of that specific user.
From here you can change certain parts of your profile. Username and Password are not able to be changed unfortunately. You will be able to change the First name, Last name, Email, and Graduating class from here. All fields must be filled in order for the data to be updated. You all have the option to delete your account through the Delete User button. It behaves similarily to the Delete User button in the "My Profile" page.