A social media website for pokemons based on the HTTP protocol
Table of Contents
In this project, we implemented a HTTP/1.1 server capable of interpreting a few HTTP requests from browsers and respond appropriately to these requests.
The request methods implemented were: GET, PUT, POST and DELETE.
The HTTP server was implemented according to the RFC 2616, which defines the HTTP/1.1 protocol.
You can read the code documentation here:
# Clone the repository
$ git clone https://github.com/WebisD/http-api-without-lib.git
# Access the project folder in your terminal / cmd
$ cd http-api-without-lib
# Run the application
$ python3 main.py
# The application will open on the port: 8083 - go to http://localhost:8083
In your browser, go to http://localhost:8083
This page and any other you navigate through the menu symbolizes a GET on our server
Each image on the website is treated separately and has its own GET
In your browser, go to http://localhost:8083
and click in Add new friends
Then, fill in the fields and clik in Add
This will send a POST request to the server which will handle the data, store it in the databse and return the outcome of the operation
The image is received by the server as data-uri that downloads the image and stores it locally
In your browser, go to http://localhost:8083
and click in See your friends
Choose the friend you want to edit the information of and click Edit
Fill in the fields and clik in Save Changes
This will send a PUT request to the server requesting the replacement of the information
If it's an image, the server will delete the last image and replace with the new one
In your browser, go to http://localhost:8083
and click in See your friends
-
Delete one friend
Choose a friend you want to delete the information of and click
Delete
-
Delete all friends
If you want to delete all of your friends' information click
Delete All
In both cases, the button will send a DELETE request to the server that will delete the image and the info related with that friend
In most cases, the server will return status codes on your browser console (which you can see by pressing F12
) saying whether the operation was successful or not
Here are the most common status codes and how you can see them
-
This is the state that you will see the most, whenever a GET is successful this status code will be shown
-
This status will occur when you click
Add
to add a new friend on theAdd new friend
's page
-
For this state to occur it is a little more complicated. Go to our server and access this directory
./databaseUser/Images
Now, feel free to move some of the images around (just don't take it out of the main folder of this project)
If you try a GET or click on
list all friends
, you can see this status code and the new image path on the terminal
-
If the fields to register a friend are not completely filled out, an error will occur and will be shown in the browser (as in the following gif) and in the terminal
-
If the requested page does not exist, an error will occur and will be shown in the browser
On this page, you can play the famous google dinosaur game or go back to the main page
-
In case you see this, something happened to our server and we will resolve it soon
Antonio Gustavo | Joรฃo Vitor Dias | Weverson da Silva |
---|---|---|
22.1190001-0 | 22.119.006-9 | 22.119.004-4 |