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 …
Using Terraform, creating Thumbnail Image in AWS Lambda with AWS S3 trigger
In this video, we will be writing an AWS Lambda function that creates a thumbnail image which is triggered whenever an image is uploaded to a S3 bucket with AWS S3 trigger and deployed using Terraform. Source code can be found here.
We'll first initialize the project
$ export AWS_PROFILE=arundhaj …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 …5 Responsive Layouts built with Angular FlexLayout
I came across an article Learn CSS Flexbox by Building 5 Responsive Layouts in which the author neatly explains the concept. As I'm extensively using Angular, Angular Material and Angular FlexLayout, I though of reproducing the layouts with FlexLayout.
Layout 1 - Responsive Card Layout
This is a responsive card layout …
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 …