mirror of
https://github.com/thelounge/thelounge
synced 2024-11-10 06:34:21 +00:00
Implemented a simple web server
This commit is contained in:
parent
196f9aa551
commit
e65c9130c0
5 changed files with 51 additions and 1 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
node_modules/
|
14
app.js
14
app.js
|
@ -1 +1,13 @@
|
|||
console.log("Hello, world.");
|
||||
var argv = require("commander")
|
||||
.option("-p, --port <n>", "port to use", parseInt)
|
||||
.parse(process.argv);
|
||||
|
||||
PORT = 80; // Default port.
|
||||
if (argv.port) {
|
||||
PORT = argv.port;
|
||||
}
|
||||
|
||||
// Run the server!
|
||||
var Server =
|
||||
new (require("./lib/server.js"))()
|
||||
.listen(PORT);
|
||||
|
|
1
client/index.html
Normal file
1
client/index.html
Normal file
|
@ -0,0 +1 @@
|
|||
Hello, world.
|
30
lib/server.js
Normal file
30
lib/server.js
Normal file
|
@ -0,0 +1,30 @@
|
|||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var connect = require("connect");
|
||||
|
||||
/**
|
||||
* Export module.
|
||||
*/
|
||||
|
||||
module.exports = Server;
|
||||
|
||||
/**
|
||||
* The Server class.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
|
||||
function Server() {
|
||||
|
||||
/**
|
||||
* Start the server.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
|
||||
this.listen = function(port) {
|
||||
connect().use(connect.static("client")).listen(port);
|
||||
};
|
||||
};
|
6
package.json
Normal file
6
package.json
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"dependencies": {
|
||||
"connect": "2.13.0",
|
||||
"commander": "2.1.0"
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue