Verify Google Auth Token (Google Sign) Using Python

Verify Google Auth Token (Google Sign) Using Python

Tiempo de lectura: 2 minutos Today we’re going to learn how we can verify a token generated with Google Sign-In from a front-end client by sending it to the back-end. In this case, we’ll be using Python. Of course, here’s a step-by-step tutorial for validating a Google Sign-In token in Python using the google-auth library. Step 1: Install the google-auth … Read more

Send PUSH Notifications to Google Firebase Cloud Messaging API (V1) using Python

Send PUSH Notifications to Google Firebase Cloud Messaging API (V1) using Python

Tiempo de lectura: 3 minutos Today we are going to learn how we can send a message to the Firebase Cloud Messaging endpoint using Python. (https://firebase.google.com/docs/cloud-messaging/http-server-ref?hl=es-419) For this, we need the Google endpoint: POST https://fcm.googleapis.com/v1/projects/myproject-b5ae1/messages:send And previously we have to generate a token in our application, for this we go to Firebase, select our project, and click on Project Settings: … Read more

Creating a websocket with FastAPI

Creating a websocket with FastAPI

Tiempo de lectura: 2 minutos Today we are going to learn how we can quickly and easily generate a websocket with FastAPI. Step 1: Environment Setup, if you already have FastAPI installed, you can skip these steps. Make sure you have Python installed on your system. Then, install FastAPI and Uvicorn using pip: pip install fastapi uvicorn Step 2: Create … Read more

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