const file = require ( 'fs' ); const result = file . writeFileSync ( "hello.txt" , "Hello my name is aditya" ); console . log ( result ); //hello.js console . log ( "hello" ); const math = require ( "./math" ); //console.log(math.add(3,5)); const value = math. add ( 3 , 5 ); console . log ( value ); //maths export function add ( a , b ){ return a + b ; } function sub ( a , b ){ return a - b ; } //we have to export functions to use them in other files because we run the server with only one file module . exports = { add , sub }; //server.js const http = require ( "http" ); const fs = require ( 'fs' ); const myserver = http . createServer (( req , res ) => { const log = ` ${ Date . now ()} : ${ req . url } :The request recieved \n ` ; fs . appendFile ( 'serverlog.txt' , log , ( req , res ) => { }) // console.log("request recieved"); switch ( req .url){ ...
Comments
Post a Comment