Speed up development with full-stack environments for every branch.

Learn More

View Nodejs [Node.js and Hello World]

Forked from Hello World for Node.js.

20 Runs 43 Views 2 Copies

Hello world in Node.js

Saved

Saved

BlueCC 1

BlueCC
published 3 months ago

    var cookieSession = require('cookie-session');
    var express = require('express');
    
    var app = express();
    
    // app.set('trust proxy', 1); // trust first proxy
    
    app.use(cookieSession({
      name: 'session',
      keys: ['key1', 'key2']
    }));
    
    app.get('/', function (req, res, next) {
      // Update views
      req.session.views = (req.session.views || 0) + 1;
    
      // Write response
     console.log(req.session.views + ' views')
    });
    
    app.listen(80);
    
    Please login/signup to get access to the terminal.

    Your session has timed out.

    Dismiss (the page may not function properly).