Difference between revisions of "Express.js"

From air
Jump to navigation Jump to search
 
Line 18: Line 18:
 
Browse http://localhost:3000
 
Browse http://localhost:3000
   
  +
  +
==Extra : [[HTTPS]]==
  +
<pre>
  +
mkdir cert
  +
cd cert
  +
openssl genrsa 1024 > key.pem
  +
openssl req -x509 -new -key key.pem > key-cert.pem
  +
</pre>
  +
  +
  +
<pre>
  +
ar express = require('express')
  +
, fs = require('fs')
  +
, routes = require('./routes');
  +
  +
var privateKey = fs.readFileSync('cert/key.pem').toString();
  +
var certificate = fs.readFileSync('cert/key-cert.pem').toString();
  +
  +
// To enable HTTPS
  +
var app = module.exports = express.createServer({key: privateKey, cert: certificate});
  +
..
  +
</pre>
   
 
==Ressources==
 
==Ressources==

Latest revision as of 21:48, 1 September 2014

http://expressjs.com

sudo npm install -g express

sudo npm install -g express-generator
express --help

express -e myapp
cd myapp
ls -al

sudo npm install
DEBUG=myapp ./bin/www

Browse http://localhost:3000


Extra : HTTPS

mkdir cert
cd cert
openssl genrsa 1024 > key.pem
openssl req -x509 -new -key key.pem > key-cert.pem


ar express = require('express')
  , fs = require('fs')
  , routes = require('./routes');

var privateKey = fs.readFileSync('cert/key.pem').toString();
var certificate = fs.readFileSync('cert/key-cert.pem').toString();  

// To enable HTTPS
var app = module.exports = express.createServer({key: privateKey, cert: certificate});
..

Ressources