Thursday, July 14, 2016

Making a super simple express server

sequential terminal command

mkdir "simpleServer"
cd simpleServer
npm init -y
npm i --save-dev express
touch server.js
touch index.html

now open server.js and paste following code
var host = "localhost"; var port = 3000; var express = require('express'); var app = express(); app.use('/', express.static(__dirname + '/')); app.listen(port, host); console.log("runnin server at http://localhost:" + port )
now open index.html and paste following code
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>super simple server</title>
</head>
<body>
    <h1>This is the Headline</h1>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Officia possimus, repellendus quaerat debitis, necessitatibus natus quisquam et magnam reiciendis mollitia placeat nulla rem totam dolores adipisci ullam. Repellat, eligendi accusantium.</p>
</body>
</html>
now open package.js and replace the scripts object by following scripts objects
"scripts": { "start" : "node server.js" },




css snippet for blogger code highlighting

code, .code {     display: block;     background: beige;     padding: 10px;     margin: 8px 15px; }