{"id":651,"date":"2022-05-20T14:10:47","date_gmt":"2022-05-20T14:10:47","guid":{"rendered":"http:\/\/mipython.magwebdesigns.net\/WP\/?p=651"},"modified":"2022-05-20T14:11:21","modified_gmt":"2022-05-20T14:11:21","slug":"node-js-and-express-tutorial-1","status":"publish","type":"post","link":"http:\/\/mipython.magwebdesigns.net\/WP\/2022\/05\/20\/node-js-and-express-tutorial-1\/","title":{"rendered":"NODE JS and EXPRESS Tutorial 1"},"content":{"rendered":"\n<p><a href=\"https:\/\/replit.com\/@MANDREWS85\/NodeHTTPServer-Templates-Express#index.js\">NODE JS and EXPRESS Tutorial 1<\/a><\/p>\n\n\n\n<p>First lets install Express after we have installed Node.<\/p>\n\n\n\n<pre class=\"wp-block-code\">\n\n<div class=\"codecolorer-container text blackboard\" style=\"overflow:auto;white-space:nowrap;width:800px;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\">npm install express<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n\n<\/pre>\n\n\n\n<p>Let us again make our index.html file<\/p>\n\n\n\n<pre class=\"wp-block-code\">\n\n<div class=\"codecolorer-container text blackboard\" style=\"overflow:auto;white-space:nowrap;width:800px;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/>2<br \/>3<br \/>4<br \/>5<br \/>6<br \/>7<br \/><\/div><\/td><td><div class=\"text codecolorer\">var fs = require('fs');<br \/>\n<br \/>\n\/\/ &nbsp; MAKE NEW FILE NAMED INDEX.HTML<br \/>\nfs.open('index.html', 'w', function (err, file) {<br \/>\n&nbsp; if (err) throw err;<br \/>\n&nbsp; console.log('SAVED NEW INDEX.HTML FILE');<br \/>\n});<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n\n<\/pre>\n\n\n\n<p>And append some new HTML<\/p>\n\n\n\n<pre class=\"wp-block-code\">\n\n<div class=\"codecolorer-container text blackboard\" style=\"overflow:auto;white-space:nowrap;width:800px;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/>2<br \/>3<br \/>4<br \/>5<br \/><\/div><\/td><td><div class=\"text codecolorer\">\/\/ APPEND FILE INDEX.HTML<br \/>\nfs.appendFile('index.html', 'new text', function (err) {<br \/>\n&nbsp; if (err) throw err;<br \/>\n&nbsp; console.log('APPENDING INDEX.HTML FILE');<br \/>\n});<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n\n<\/pre>\n\n\n\n<p>Lets start our Express server and serve the file.<\/p>\n\n\n\n<pre class=\"wp-block-code\">\n\n<div class=\"codecolorer-container text blackboard\" style=\"overflow:auto;white-space:nowrap;width:800px;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/>2<br \/>3<br \/>4<br \/>5<br \/>6<br \/>7<br \/>8<br \/>9<br \/>10<br \/><\/div><\/td><td><div class=\"text codecolorer\">var express = require(&quot;express&quot;);<br \/>\nvar app &nbsp; &nbsp; = express();<br \/>\nvar path &nbsp; &nbsp;= require(&quot;path&quot;);<br \/>\n<br \/>\napp.get('\/',function(req,res){<br \/>\n&nbsp; res.sendFile(path.join(__dirname+'\/index.html'));<br \/>\n});<br \/>\n<br \/>\napp.listen(3000);<br \/>\nconsole.log(&quot;Running at Port 3000&quot;);<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n\n<\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>NODE JS and EXPRESS Tutorial 1 First lets install Express after we have installed Node. Let us again make our index.html file And append some new HTML Lets start our Express server and serve the file.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"nf_dc_page":"","_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-651","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"http:\/\/mipython.magwebdesigns.net\/WP\/wp-json\/wp\/v2\/posts\/651","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/mipython.magwebdesigns.net\/WP\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/mipython.magwebdesigns.net\/WP\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/mipython.magwebdesigns.net\/WP\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/mipython.magwebdesigns.net\/WP\/wp-json\/wp\/v2\/comments?post=651"}],"version-history":[{"count":3,"href":"http:\/\/mipython.magwebdesigns.net\/WP\/wp-json\/wp\/v2\/posts\/651\/revisions"}],"predecessor-version":[{"id":654,"href":"http:\/\/mipython.magwebdesigns.net\/WP\/wp-json\/wp\/v2\/posts\/651\/revisions\/654"}],"wp:attachment":[{"href":"http:\/\/mipython.magwebdesigns.net\/WP\/wp-json\/wp\/v2\/media?parent=651"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/mipython.magwebdesigns.net\/WP\/wp-json\/wp\/v2\/categories?post=651"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/mipython.magwebdesigns.net\/WP\/wp-json\/wp\/v2\/tags?post=651"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}