CRUD Applications with Flask
2
0

CRUD Applications with Flask

Marcelo Gomes Feitoza
0 min
2
0
Email image

What is Flask?

Flask is a micro-framework in Python. It makes it easier to start a server, and when it is combined with other modules it can build sophisticated and complex applications.

It is considered a micro-framework because it does not need any particular tool or libraries in order to work properly.

Flask is a great tool to work with for back-end applications, and it is widely used for big companies, such as Netflix, Airbnb, Reddit, and others.

What is a CRUD Application?

CRUD Applications are the applications that are able to:

  • Create- like adding a new book to a catalog.
  • Read- being able to see all the books in the catalog.
  • Update- change a book's name.
  • Delete- delete a book from the catalog.


All of these actions seem to be simple when separated, but they add very important functionality to the application and can be not so easy to implement.

These 4 'simple' actions are vital to modern web development, once almost (if not all) big applications like social networks and streaming services are all using them and could not exist without them!

Key Definitions

  • Resource- A noun that we operate on. An application can have many resources, but each resource will have its own set of routes and CRUD operations. Users and Tweets are a resource of Twitter.
  • HTTP- The protocol that clients and servers use to communicate.
  1. GET: for retrieving information or sending information via the query string.
  2. POST: for sending information via the body of the request.
  3. PUT: for updating an entire resource.
  4. PATCH: for updating a part of a resource.
  5. DELETE: for deleting a resource.
  • Idempotent- An operation is idempotent if calling it multiple times yields the same result. GET requests should be Idempotent.

GET vs POST

GET is usually faster.


POST is always more secure if the information isn't transmitted in the query string.


GET is Idempotent, POST is not.

Example

Check out on GitHub an example of CRUD application that can create snacks (Create), show all of the snacks in the list (Read), change some details about the snack (Update), and delete them (Delete).

Link: https://github.com/marcelofeitoza/SnackCRUD

localhost:5000/snacks
localhost:5000/snacks
localhost:5000/snacks/create
localhost:5000/snacks/create
localhost:5000/snacks/((name))
localhost:5000/snacks/((name))
localhost:5000/snacks/((name))/edit
localhost:5000/snacks/((name))/edit

Thanks for reading!