arundhaj

all that is technology

How to Configure and Use Flask-CORS

 

Cross-Origin Resource Sharing (CORS) is a security feature implemented by web browsers that controls how web pages in one domain can request and interact with resources hosted on another domain. When building a Flask API that will be accessed by a frontend running on a different port or domain, you'll …

Using Django ORM Collector to Get Dependent Tables with Foreign Keys

 

When working with Django applications, you might need to find all dependent records that reference a particular model instance through foreign key relationships. Django's ORM provides a powerful tool called Collector that can help you identify and collect all related objects before performing operations like deletion.

In this article, we'll …

Routing in Python Flask and HTTP Methods

 

In this article and video, we’ll see how to write RESTful APIs using Python Flask for the required behavior.

The route decorator is used to define the behavior of APIs. It can be applied to a method or class. Below is the basic use of route.

@app.route('/user …

Creating AWS S3 Presigned URL for uploading and downloading files in Python using Boto3

 

In this video I'll show how create AWS S3 presigned URL for uploading and downloading files in Python using Boto3.

You can find the code snippet below

from pprint import pprint

import boto3

session = boto3.Session(profile_name='arundhaj')

s3_client = session.client('s3')

s3_bucket_name = 'codepossibility-presigned'
object_name = 'TestUploadFile.txt'


def create_bucket():
    response …

Using SQLAlchemy Expression for Insert

 

In this article, I'll show how to build SQLAlchemy expressions for various cases of inserting data to the table

For simple insert,

# Prepare the statement
insert_stmt = insert(TableName).values(Column1='Column1Value', Column2='Column2Value')

# Execute the statement
insert_result = db.session.execute(insert_stmt)

# Get the Primary Key of the newly inserted record …

Customizing AWS Amplify color scheme for Angular

 

In this article, I'll show you how to customize AWS Amplify color scheme for Angular apps.

Following are the list of variables with the default values exposed by AWS Amplify for customization.

:root {
  --amplify-primary-color: #ff9900
  --amplify-primary-contrast: var(amplify-white)
  --amplify-primary-tint: #ffac31
  --amplify-primary-shade: #e88b01
  --amplify-secondary-color: #152939
  --amplify-secondary-contrast: var(amplify-white)
  --amplify-secondary-tint …

Dynamically Change Page Title for each Route in Angular

 

In this article, I'll show you how to dynamically change page title of an Angular app based on Route configuration.

Let say we have three components HomeComponent, MainComponent and AboutComponent. The corresponding route definition as in app-routing.module.ts file

import { NgModule } from "@angular/core";
import { RouterModule, Routes } from "@angular …

Multiple head revisions present ERROR in Flask Migrate

 

In this article, I'll show you the cause of the following error and how to fix it.

ERROR [root] Error: Multiple head revisions are present for given argument 'head'; 
    please specify a specific target revision, '<branchname>@head' to narrow 
    to a specific head, or 'heads' for all heads

This error …