Skip to content

Semiannual project of the Advanced Topics in Networks discipline, taught at Centro Universitário FEI. It is a server, which allows, through a web page, to perform Http requests (GET, POST, PUT, DELETE)

License

Notifications You must be signed in to change notification settings

antuniooh/http-api-without-lib

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GitHub language count GitHub repo size GitHub last commit GitHub


Logo

Pokebook

A social media website for pokemons based on the HTTP protocol

Made with python

Table of Contents
  1. About The Project
  2. Documentation
  3. How To Run
  4. Methods
  5. Status Codes
  6. Authors

💻 About The Project

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.

app

📖 Documentation

You can read the code documentation here:

a

🚀 How To Run

# 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

🛠 Methods

🤲 GET

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

get

📮 POST

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

post

🔀 PUT

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

put

🗑️ DELETE

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

delete

📜 Status Code

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

Successful 2xx

  • 200 OK 👍

    This is the state that you will see the most, whenever a GET is successful this status code will be shown

  • 201 Created 🆕

    This status will occur when you click Add to add a new friend on the Add new friend's page

Redirection 3xx

  • 301 Moved Permanently 👉

    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

    moved

Client Error 4xx

  • 400 Bad Request 👎

    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

    badpost

  • 404 Not Found 🤷‍♂️

    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

    erro

Server Error 5xx

  • 500 Internal Server Error

    In case you see this, something happened to our server and we will resolve it soon

🤖 Authors

Antonio Gustavo João Vitor Dias Weverson da Silva
drawing drawing drawing
22.1190001-0 22.119.006-9 22.119.004-4

About

Semiannual project of the Advanced Topics in Networks discipline, taught at Centro Universitário FEI. It is a server, which allows, through a web page, to perform Http requests (GET, POST, PUT, DELETE)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • HTML 79.0%
  • Python 20.2%
  • CSS 0.8%