Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- browser="google-chrome"
- mkdir node_server
- cd node_server
- if [ ! -f "/usr/bin/nodejs" ]
- then
- sudo apt-get install nodejs
- fi
- npm install --save express@4.10.2
- echo """
- var express = require('express')
- var app = express()
- app.get('/', function (req, res) {
- res.send('<h1>Hello World!</h1>')
- console.log("Someone Connected and I said Hello!!!");
- })
- app.get('/dir', function (req, res) {
- var exec = require('child_process').exec;
- exec('find /usr', function (error, stdout, stderr) {
- // output is in stdout
- res.send(stdout)
- });
- })
- var server = app.listen(3000, function () {
- var host = server.address().address
- var port = server.address().port
- console.log('Example app listening at http://%s:%s', host, port)
- })
- """ > server.js
- $browser "http://127.0.0.1:3000"
- nodejs server.js
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement