Complete Guide to HTTP Status Codes: Understanding Web Server Messages

Tiempo de lectura: 2 minutos Good morning! And happy holidays! 🎄 Today I bring you a basic tutorial about HTTP status codes. It’s always good to have them handy, so here are the most common ones! Common HTTP status codes: 200 OK: The request has been successfully processed. 400 Bad Request: Error in the client’s request. It could be due … Read more

Deploying a Python Web Application with Docker and Flask

Deploying a Python Web Application with Docker and Flask

Tiempo de lectura: < 1 minuto In this tutorial, we will learn how to use Docker to deploy a basic Python web application using the Flask framework. :snake: Step 1: Project Structure Create a new folder named “MyAppFlask” in your project directory and navigate to it: mkdir ~/projects/MyAppFlask cd ~/projects/MyAppFlask Step 2: Flask Application Code Create a file named app.py with … Read more

Encrypt a file and get it decrypted using FAST-API

Encrypt a file and get it decrypted using FAST-API

Tiempo de lectura: 2 minutos Today we are going to learn how to store an encrypted file and how to decrypt it to return it in a response. We will use the Fernet library. pip install cryptography First, let’s create an encryption key with Fernet. def generate_key(): key = Fernet.generate_key() return key.decode(‘utf-8’) With this function, we can obtain a random … Read more

How to Handle Errors and Send Emails in Case of Exceptions in FastAPI

How to Handle Errors and Send Emails in Case of Exceptions in FastAPI

Tiempo de lectura: 2 minutos In FastAPI development with Python, proper error handling is crucial to ensure smooth operation. In this tutorial, we will learn to implement an exception handling system that will automatically send an email to the administrator when an error occurs in our API. Step 1: Setting up the handler.py File Firstly, we will create a file … Read more

How to Create an Interceptor or Middleware to Obtain X-REAL-IP and X-Forwarded-For in Calls with FAST-API

How to Create an Interceptor or Middleware to Obtain X-REAL-IP and X-Forwarded-For in Calls with FAST-API

Tiempo de lectura: 2 minutos Hello, today I bring you a tutorial on how to create an interceptor or middleware in FastAPI to obtain the X-REAL-IP and X-Forwarded-For headers in API calls: Introduction In FastAPI, interceptors (middlewares) are a powerful tool that allows you to customize the handling of HTTP requests before or after they reach the route handlers. In … Read more

How to Encrypt Data in a MySQL Database Table with FastAPI and SQLAlchemy

How to Encrypt Data in a MySQL Database Table with FastAPI and SQLAlchemy

Tiempo de lectura: 2 minutos In this tutorial, you will learn how to encrypt sensitive data in a MySQL database table using FastAPI and SQLAlchemy. Encryption is essential for protecting the confidentiality of data stored in a database and ensuring its security. In this example, we will use SQLAlchemy to model the database and the Fernet function from the cryptography … Read more

Post Tweets with Image Using Python Twitter API v2

Post Tweets with Image Using Python Twitter API v2

Tiempo de lectura: 2 minutos Reading Time: 2 minutes Hello, today we are going to learn how to publish Tweets with images using Python with the Twitter API v2. The first thing we need to do is create a Twitter APP, for that, consult one of the previous tutorials. Let’s install the necessary libraries: pip install python-dotenv pip install requests … Read more