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

Obtener subtítulos de un vídeo de Youtube con Python

Obtener subtítulos de un vídeo de Youtube con Python

Tiempo de lectura: 2 minutos Reading Time: < 1 minute Hello, today we’re going to learn how to get subtitles from a YouTube video using a Python library. The first thing we need to do is install the library: pip install youtube-transcript-api You can find this library here: https://pypi.org/project/youtube-transcript-api/ To use it and get the subtitles from a video, we ... Read more

Automate a Task with Ofelia Cron in Docker and FastAPI

Automate a Task with Ofelia Cron in Docker and FastAPI

Tiempo de lectura: < 1 minuto Reading Time: 1 minute Hello, today we are going to learn how to automate a task using Ofelia, FastAPI, and SQLAlchemy. The first thing we are going to do is create the file that we want to execute with Ofelia’s Cron: cron_execute.py # Create or get db_session from crud.operations_crud import operacion_crud_generar_estadisticas from config.connection import get_db … Read more

Get and Return PDF File Using FAST-API

Get and Return PDF File Using FAST-API

Tiempo de lectura: < 1 minuto Reading time: < 1 minute Hello, today we are going to see how we can retrieve a saved PDF file and return it using Fast API with Python. We go to our routes file and add the necessary dependencies (in addition to those of Fast API): import os from fastapi.responses import FileResponse Now we are ... Read more