generated from dr-btd-student/p4
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebServer.js
More file actions
28 lines (21 loc) · 858 Bytes
/
webServer.js
File metadata and controls
28 lines (21 loc) · 858 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
"use strict";
/*
* A simple Node.js program for exporting the current working directory via a
* webserver listing on a hard code (see portno below) port. To start the
* webserver run the command: node webServer.js
*
* Note that anyone able to connect to localhost:3001 will be able to fetch any
* file accessible to the current user in the current directory or any of its
* children.
*/
/* jshint node: true */
var express = require("express");
var portno = 3000; // Port number to use
var app = express();
// We have the express static module
// (http://expressjs.com/en/starter/static-files.html) do all the work for us.
app.use(express.static(__dirname));
var server = app.listen(portno, function () {
var port = server.address().port;
console.log("Listening at http://localhost:" + port + " exporting the directory " + __dirname);
});