javascript - Running Node.js Server using User Level Root -


basic question not sure turn start figuring out.

i've setup simple node server on port 3000 responds index.html file. when call http://localhost:3000 in browser, proper page served dependencies. don't want authenticate every time though i'd run user-level.

i tried typing http://localhost~myusername:3000 in browser keep getting:

the requested url /~myusername:3000 not found on server.

(i have setup user-level root accessed through ~/sites , have gotten access files through here, php, it's when start using node server problem occurs.)

how can node.js respond user-level requests? , serve proper index.html relative path of user-level root instead of /library/webserver/documents?

update code of server.js:

var http = require('http'); var fs = require('fs');

function send404(response) {     response.writehead(404, { 'content-type': 'text/plain' });     response.write('error 404: resource not found.');     response.end(); }  var server = http.createserver(function (req, res) {     if (req.method == 'get' && req.url == '/') {         res.writehead(200, { 'content-type': 'text/html' });         fs.createreadstream('./index.html').pipe(res);     }     else {         send404(res);     } }).listen(3000); console.log('server running on port 3000'); 


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -