Posts

Setup Flask Project

Image
Prerequisite Python What Is Flask ? Flask is a lightweight Web framework written in Python. It is developed by  Armin Ronacher. Flask is based on the Werkzeug WSGI toolkit and Jinja2 template engine Setup Development Environment First Install virtualenv virtualenv  is a virtual python environment builder.virtualenv    is used to manage python packages for different projects. Using virtualenv allows you to avoid installing python packages globally which could break system tools or other projects. Install the virtualenv using the following command.This command needs administrator privileges # pip install virtualenv After installing the virtualenv . Make Folder create new folder using the following command  # mkdir flaskdemo change to the current created directory/folder # cd flaskdemo Create Virtual Environment In Folder Now we will create a virtualenv .  The commands below will create a new directory named virtual_env inside our pr

Upload Image Using AJAX In Node

Image
Introduction In this blog we see how we can upload image file using ajax.Here we be using FileReader  for reading the selected file and then we send that file data to server side using ajax and on server side we read and save that as image on server. Project Structure Setup Folder Open the command prompt and create new folder using following command mkdir upload Now change   to the newly created folder by using folder command cd upload Setup Node In Folder Now we have to setup node environment in the folder for our project. We have to use the below command to setup node in our folder npm init -y This command will create a package.json file which indicates that node is initialized in folder. The package.json file will look like this Install Packages Now we have to install the package required for building the application. For installing packages we use npm install followed by package name. n

How to Use AJAX with Node

Image
Project Structure                |-------------- models        |                          |-------------- task.js                                    |         |-------------- public        |                          |-------------- data.js        |            |--------------- routes         |                          |-------------- taskroute.js        |         |--------------- views        |                          |-------------- demo.ejs        |         |--------------- app.js Setup The Folder To create a folder, open the command prompt and type cmd mkdir followed by the folder name    # mkdir ajax Change to the folder by typing the cmd cd followed by the folder name  # cd ajax  Setup Node In Folder On the console, type the below command   # npm init -y This will create a package.json file, Which means that node is initialised in the folder. the package.json will look like this  Install Pack

Import CSV File Data Into MongoDB In Node

Image
Setup Folder Open the command prompt and create new folder using the following command followed by folder name. mkdir csv After creating the folder.Change to that folder by using the following command cd csv Setup Node In Folder To setup node in folder use the following command npm init -y This will setup node in our folder.And  after the execution of this command you will see package.json file which means node is initialised. This package.json file will contain the metadata related to our project. The package.json will look like this Install Packages Now we have to install packages to be used to build our application. To install packages we use the following command followed by package name.  npm install csvtojson express ejs mongoose multer body-parser  After installation package.json will look like this Add New Folders Add few new folders in our project folder  models public views Models Folder Add new file

Adding Searching Functionality In Node

In this article we see how we can enable the searching of data from server in our node application. Setup The Folder  a) Make a new folder using command prompt.Type the following command. mkdir search b) change to the new folder cd search Setup Node In Folder For setting up node we type the following command npm init -y it will initialize the node in our project. And we get a package.json file in our folder. Which  means node is initialized in our folder. Install Packages Now we install the packages which will be required for building the application. npm install express ejs body-parser mongoose. Add New Folder models views models - this will contain our schema of collections(table). views - will contain the ejs pages.   Model Add new file in folder name it data.js Views Add 2 folders a)pages b)partial In partial folder add 2 new files header.ejs and footer.ejs header.ejs footer.ejs In pages add home.ejs file.

Hashing Password With Bcrypt In Node

Image
Image by Jae Rue from Pixabay Introduction In this article we will be using the bcryptjs javascript library for hashing and compare password.Here we will build a simple api fore register and login.when we will hash the password when user register and then compare that password with hash when they login. What is bcrypt ? bcrypt is a  password hashing function  designed by  Niels Provos  and David Mazières, based on the  Blowfish  cipher, and presented at  USENIX  in 1999.Besides incorporating a  salt  to protect against  rainbow table  attacks, bcrypt is an adaptive function: over time, the iteration count can be increased to make it slower, so it remains resistant to  brute-force search  attacks even with increasing computation power. What is hashing ?  Hashing is a one way function (well, a mapping). It's irreversible, you apply the secure hash algorithm and you cannot get the original string back. The most you can do is to generate what

How To Use Sequelize-Cli In Node

Image
Introduction   In this article we will see how to use sequelize-cli for creating table in our database.and how can we setup a relationship between two table using foreignKey using sequelize Project Structure Setup The Node Project Open the console and  type the below cmd to make a new directory.         # mkdir seqlcli Then change to that directory by typing below cmd.         # cd seqlcli Setup Node In Project Now  type the below cmd on console and that will generate the package.json file.       # npm init  It will ask you to provide the basic details related to the package.json file have like name,version,author etc. After the file is initialize we can build our node project. The file will have all the metadata related to our project. Install Packages Now we will install the package which are required for building our application. On console type         # npm install express,body-parser,sequelize,mysql2,sequelize-cli So what th