Routes in Flask

- Andrés Cruz

En español
Routes in Flask

There are different HTTP methods that we can use to make requests to the server; these methods are nothing more than a set of verbs that are used to perform different types of actions; the most common methods are GET, POST, PUT, PATCH, and DELETE:

  • GET: used to get information from a web server. The information is sent in the request URL.
  • POST: used to send information to a web server. The information is sent in the body of the request.
  • PUT: used to update information on a web server. The information is sent in the body of the request.
  • PATCH: used to partially update information on a web server. The information is sent in the body of the request.
  • DELETE: used to delete information from a web server. The information is sent in the request URL.

All of these methods have their equivalent in Flask; at the moment we have used GET type methods to obtain data, but it is also possible to use others:

@app.route(<URI>, methods=('GET'))
@app.route(<URI>, methods=('POST'))
@app.route(<URI>, methods=('PUT'))
@app.route(<URI>, methods=('PATCH'))
@app.route(<URI>, methods=('DELETE'))

You can indicate several that more than one method is resolved by the same controller:

@app.route(<URI>, methods=('GET', 'POST'))

As you can see, we have a decorator function for each type of method and it has a direct relationship with the HTTP request type.

Andrés Cruz

Desarrollo con Laravel, Django, Flask, CodeIgniter, HTML5, CSS3, MySQL, JavaScript, Vue, Android, iOS, Flutter

Andrés Cruz en Udemy

Acepto recibir anuncios de interes sobre este Blog.

!Cursos a!

10$

En Udemy

Quedan 3 días!

Udemy

!Cursos desde!

4$

En Academia

Ver los cursos

!Libros desde!

1$

Ver los libros
¡Hazte afiliado en Gumroad!
!Web Alojada en Hostinger!