How Do I Create a Blog With Node Js?

Creating a blog with Node.js can be done in a few simple steps.

Firstly, create a new directory on your computer to house your blog files. Next, install the necessary Node.js dependencies by running the following command in that directory:.

npm install

Next, create a file called server.js in that directory and add the following code:

var express = require ( ‘express’ ); var app = express (); app . use ( express . bodyParser ( ‘body-parser’ )); app . session ({ secret : ‘secret’ })); app . cookieParser ( ‘cookie-parser’ )); app .

urlencodedString ()); app . use ( require ( ‘@angular/platform-browser’ ). module ( ‘ui.router’ )); // required for ngRoute app . use ( require ( ‘@angular/router’ ). routing ); // required for ngRoute var port = process . env [ ‘PORT’ ]; // set this to the port where your server will be running // if you’re using a remote server, uncomment this line and set the appropriate port var url = “http://localhost: ” + port ; // set this to the URL of your blog application app . get ( url ). pipe ( app );.

Next, create a file called index.html in that directory and add the following code:

Node Js Blog

Node Js Blog

This is my first blog!

Finally, create a file called styles.css in that directory and add the following CSS:

/* global styles */ body { background-color : #f5f5f5 ; margin : 0 ; padding : 0 ; } h1 , p { margin : 20px 0 ; } /* styles for the index page */ ul { list-style-type : none ; margin : 0 auto ; padding : 0 ; } li { display : inline-block ; margin : 0 10px 10px 10px ; text-align : center ; vertical-align : middle ; }.

Related Posts