From 5408c4b46512be32a4e085687168167a042f0858 Mon Sep 17 00:00:00 2001 From: GammaNu/Millicent Billette Date: Tue, 28 Feb 2017 12:00:34 +0100 Subject: [PATCH] =?UTF-8?q?ajout=20d'un=20mini=20serveur=20pour=20fichier?= =?UTF-8?q?=20statiques=20lan=C3=A7able=20avec=20npm=20start.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 8 ++++++-- srv/index.js | 17 +++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 srv/index.js diff --git a/package.json b/package.json index 7f526d3..6f41141 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,9 @@ "build.stylus": "stylus --compress staticApp/style.styl build/style.built.css", "build.assets": "", "build.cleaning": "", - "build.test": "" + "build.test": "", + "srv": "node srv/index.js", + "start": "npm run srv" }, "repository": { "type": "git", @@ -33,13 +35,14 @@ "homepage": "https://1twitif.github.io/social-viz/", "dependencies": { "d3": "^4.5.0", + "express": "^4.14.1", "js-yaml": "^3.8.1", "requirejs": "^2.3.2" }, "devDependencies": { "bithound": "^1.7.0", "codacy-coverage": "^2.0.1", - "codeclimate-test-reporter": "^0.4.1", + "codeclimate-test-reporter": "^0.4.1", "jasmine": "^2.5.3", "karma": "^1.4.1", "karma-chrome-launcher": "^2.0.0", @@ -49,6 +52,7 @@ "karma-jasmine": "^1.1.0", "karma-phantomjs-launcher": "^1.0.2", "karma-requirejs": "^1.1.0", + "openurl": "^1.1.1", "stylus": "^0.54.5" } } diff --git a/srv/index.js b/srv/index.js new file mode 100644 index 0000000..6ec9d1d --- /dev/null +++ b/srv/index.js @@ -0,0 +1,17 @@ +const express = require('express'); +const app = express(); + +app.use(express.static('./')); + +/*app.get('/', function (req, res) { + res.send('Hello World!') +})*/ + +app.listen(3000, function () { + console.log('Version local utilisable ici : http://localhost:3000/'); + try{ + require("openurl").open("http://localhost:3000/"); + } catch(e){ + console.log("openurl non disponnible"); + } +});