Posts

Showing posts from 2020

Simple API using Python, Flask and pyodbc

Image
  Hi Guys, I recently learnt the fundamentals of python, one of widely used languages right now. It is super fast in executing and I recommend everyone to give it a try. So I decided to the create a Simple API which will connect to a SQL Server database to perform CRUD operations. Hope you enjoy.  1) Make sure you have installed python     Go to command prompt type " python --version ", it will return the installed version of python in your computer as shown in the image. If it throws an error, don't worry you can go   to https://www.python.org/downloads/ to download the latest version of python to your pc 2) Install pyodbc to connect to SQL Server Database      Go to command prompt type " pip install pyodbc " 3) Install flask to create the api application      Go to command prompt type " pip install flask " 4) Open Visual Studio Code and create a new file "sqlapi.py" and paste the following code import  pyodbc  impor...

Spinwheel using .NET Core and Winsheel.js

Image
 Hi All, Recently I had request from one of my friends to create a small application to distribute 1000 gifts among employees of a certain company. 1) There were 5 types of gifts 2) Each type had 200 gifts 3) Gifts must be given in a random way 4) Every employee must get a gift 5) They should not get a gift which is over So created a small application with a .NET Core backend, html, javascript. I used Winwheel.js to create the spinwheel. Hope you like it. 1) Solution  2) SQL Tables 3) HomeController.cs using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging; using SpinWheelAppCore.Models; namespace SpinWheelAppCore.Controllers {     public class HomeController : Controller     {         private readonly ILogger<HomeController> _logger;       ...

FedAuth Cookie Not getting Created on Safari

Hi Guys, Recently we encountered an issue in our sharepoint portal where FedAuth Cookie generated from SPFederationAuthenticationModule was not getting created on certain Safari browsers. After a long hours of testing , trials and error. We found that the issue was caused by SameSite property of the browser Cookie. So in order to fix it, I applied the below code snippet, just after the SetPrincipalAndWriteSessionToken of the SPFederationAuthenticationModule. fam.SetPrincipalAndWriteSessionToken(securityToken);                              string userAgent = Request.ServerVariables["HTTP_USER_AGENT"]; if ((userAgent.Contains("CPU iPhone OS") ||                     userAgent.Contains("iPad; CPU OS") ||                     userAgent.Contains("Macintosh; Intel Mac OS X")) &&   ...

Microservices with .NET Core Web API, EntityFrameworkCore and Ocelot API Gateway

Image
Hi Guys, I created a simple Microservices solution using .NET Core Web API, EntityFrameworkCore and Ocelot API Gateway. Hope you like it. 1) Solution  The solution consists of four .NET Core Projects. APIGateway, ProductMicroservice, UserMicroservice are Web API projects while Microsoft.DataAccess is a class library with EntityFrameworkCore. And this project is referred by ProductMicroservice, UserMicroservice. 2) UserMicroservice  This project has a simple UserController as following, namespace UserMicroservice.Controllers {     [Route("api/[controller]")]     public class UserController : Controller     {         DatabaseContext _databaseContext;         public UserController()         {             _databaseContext = new DatabaseContext();         }         // GET: api/...