MEAN Node JS: Web Server Part Creating a Simple Web Server var http = require('http'); http.createServer(function (req, res) { res.writeHead(200, {'Content-Type': 'text/plain'}); res.end('Hello World How are you !'); }).listen(8080,'localhost'); Executing the above code in Node will create a web server and when you will send the request to server using a browser it … Continue reading Node JS:101
Month: November 2017
NodeJs: HTTP Request – Response to REST API
Sending HTTP GET/POST Request and Response using Node JS. Code: var https = require("https"); exports.handler = (events,context,callback) => { var options = { host : 'hostname', port : '443', path : 'ifany', headers: { 'Authorization' : 'Basic' + new Buffer("username" + ':' + "password").toString('base64') } }; // request request = https.get(options, function(res){ var body = … Continue reading NodeJs: HTTP Request – Response to REST API
AWS Lex: Building a BOT
What are Chat Bots? Chat Bot is a service that runs on rules or Artificial intelligence The users interact using natural and conversational Language. Chat Bots are like your personal assistants that actually assist you. They can live in any chat applications like Slack, Facebook messenger, Skype etc. Common example: Weather Bots - fetches forecast, current … Continue reading AWS Lex: Building a BOT
Dynamic String Conversion in JAVA
Input: 2B Output: 2000000000 Code : import java.math.BigDecimal; import java.util.Scanner; public class DyanamicConversion { public static void main(String args[]){ //Scanner scan = new Scanner(System.in); String a ="2M"; String[][] conversion = {{"K","1000"},{"M","1000000"},{"B","1000000000"}}; for(int i=0;i<conversion.length;i++){ if(a.endsWith(conversion[i][0])){ BigDecimal temp = new BigDecimal(a.substring(0, a.indexOf(conversion[i][0]))); temp.multiply(new BigDecimal(conversion[i][1])); a = temp.toBigInteger().toString(); System.out.println(a); break; } } } }
Trigger an Email using AWS Lambda with the help of AWS SES
Using the Amazon Web Services to Trigger an email. Here we have used AWS SES service. Firstly you have to register senders email address in AWS SES app in AWS then after confirmation, you can use the SES service in Lambda. Node JS Code for Lambda: var aws = require("aws-sdk"); var ses = new aws.ses({ … Continue reading Trigger an Email using AWS Lambda with the help of AWS SES
Sending HTTP GET Request to a REST API in JAVA
HTTP/HTTPS Get/Post request /response using JAVA below. For detailed visit here: https://www.mkyong.com/java/how-to-send-http-request-getpost-in-java/ Code: import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.URL; import javax.net.ssl.HttpsURLConnection; public class HttpURLConnection { public static void main(String[] args) throws IOException { String response = httpGet("https://services.groupkt.com/state/get/IND/all"); } public static String httpGet(String urlStr) throws IOException { URL obj = new URL(urlStr); HttpsURLConnection con … Continue reading Sending HTTP GET Request to a REST API in JAVA
Parsing JSON Output using JAVA
Use the JSONParser methods to parse a response that's returned from a call to an external service that is in JSON format, such as a JSON-encoded response of a Web service callout. Here is the code to parse the JSON string using JAVA: 1 2 3 4 5 6 7 8 9 10 11 12 … Continue reading Parsing JSON Output using JAVA
Understanding Spring MVC project setup
Flow Diagram of Spring MVC Img Source: TutorialsPoint Purpose of web.xml Until Spring 3.1 the only way to configure the DispatcherServlet was with the WEB-INF/web.xml file. servlet name is dispatcher an instance of DispatcherServlet Class Will be initialized with a parameter named contextConfigLocation which contains the path to the configuration XML load-on-startup is an integer … Continue reading Understanding Spring MVC project setup
Spring MVC Project: Setup
Software Requirements Eclipse Mars 2 Java, jdk 1.6 and above Spring 4 jar files(download) Apache Tomcat 7 Step 1: Create a Dynamic Web Project(File>New>Dynamic Web Project) Step 2: Create project folder and packages as shown below Step 3: Add required Spring MVC libs Step 4: Add following code in web.xml Step 5: Add following code … Continue reading Spring MVC Project: Setup
BUILDING CHAT BOTs: MICROSOFT QnA MAKER
To find about What are Chat Bots? visit here. According to Microsoft’s documentation, “Microsoft QnA Maker is a free, easy-to-use, REST API and web-based service that trains AI to respond to user’s questions in a more natural, conversational way. Compatible across development platforms, hosting services, and channels, QnA Maker is the only question and answer service with a graphical user … Continue reading BUILDING CHAT BOTs: MICROSOFT QnA MAKER
CHAT BOT USING MICROSOFT AZURE BOT SERVICE & LUIS
What is Azure Bot Service ? For introduction to chat bots please refer this link here Azure Bot Service is a intelligent, serverless bot development service introduced by Microsoft Azure on Azure Portal. This service is used to develop conversational bots with the help of various templates, cognitive services by Microsoft. LUIS : LUIS is the Language Understanding Intelligent Service. LUIS enables developers to … Continue reading CHAT BOT USING MICROSOFT AZURE BOT SERVICE & LUIS