Posts

Showing posts from May, 2023

action posting

 calci js const express = require("express"); const app = express(); app.get("/contact", function(req, res){   res.send("surajkurle2003@gmail.com"); }) app.get("/", function(req, res){   res.sendFile(__dirname + "/index.html"); }) app.post("/", function(req, res){   res.send("thanks for posting this") }) app.listen(3000, function(){   console.log("server started at port 3000"); }) HTML code <!DOCTYPE html> <html lang="en" dir="ltr">   <head>     <meta charset="utf-8">     <title>calculator</title>   </head>   <h1>my calculator</h1>   <body>     <form action="/" method="post">       <input type="text" name="numq" placeholder="first number">       <input type="text" name="num2" placeholder="second number">       <button t...

calculator

 Js code const express = require("express"); const app = express(); app.get("/", function(req, res){   res.sendfile(__dirname + "/index.html") }) app.listen(3000, function(){   console.log("server started at port 3000"); }); index.html <!DOCTYPE html> <html lang="en" dir="ltr">   <head>     <meta charset="utf-8">     <title>calculator</title>     <h1>calculator</h1>   </head>   <body>     <form action="index.html" method="post">       <input type="text" name="num1" placeholder="first num">       <input type="text" name="num2" placeholder="second num">       <button type="submit" name="submit">calculate</button>     </form>   </body> </html>

understanding and working with routes

 const express = require("express"); const app = express(); app.get("/", function(req, res){   res.send("hello suraj") }) app.get("/contact", function(req, res){   res.send("you can contact me at : surajkurle2003@gmail.com") }) app.get("/about", function(req, res){   res.send("my name is suraj and m the greatest coder") }) app.listen(3000, function(){   console.log("server started at port 3000"); })

handling requests and response

 const express = require("express"); const app = express(); app.get("/", function(request, response){   response.send("hello suraj") }) app.listen(3000, function(){   console.log("server started at port 3000"); })

creating first server with express.js

  const express = require("express"); const app = express(); app.listen(3000, function(){   console.log("server started at port 3000"); })

node superhero/villain package

var superheroes = require("superheroes"); var supervillains = require("supervillains"); var mysupe = superheroes.random() var villains = supervillains.random() console.log(mysupe); console.log(villains);