Express not loading in URL











up vote
0
down vote

favorite












I currently have an express server I'm running based on the express tutorial.



Here is my code for server.js



const express = require('express')
const app = express()
const port = 3000

app.get('/', (req, res) => res.send('Hello World!'))

app.listen(port, () => console.log(`Example app listening on port ${port}!`))


the server.js file is in a directory on my server:



http://myurl.com/node-webshot/server.js


I start the server with: npm start
and get this:



> webshot@0.18.0 start /home/myurl/node-webshot
> node server.js

Example app listening on port 3000!


when I go to my url: http://myserver.com/node-webshot/
I see the directory listing only:
enter image description here



note "myserver.com" is just a fill in to path for working folder.



My expected result would be that when I go to the roof of the file where server.js is loaded that it would show the "Hello world". Not sure what I'm missing here.










share|improve this question






















  • simply go to http://<serverName>:port/
    – xan_z
    Nov 7 at 18:56










  • Cannot GET /preview/productpreview/node-webshot @xan_z
    – FabricioG
    Nov 7 at 19:04










  • I see your comment works, not url where I was pointing to. Since I placed server.js file in specific folder I was calling that route. @xan_z
    – FabricioG
    Nov 7 at 19:06










  • you don't call your server side files/code - they are served by the server based on the routes you have. - and hence you invoke the routes based on the server IP/DNS and port - followed by the route - as you have only one get route of '/' - that is the only thing which can be done with the above code for now.
    – xan_z
    Nov 7 at 19:11










  • Is there anyway to expose the url path with out using a port? For example I'd like to just go to the url like this "myurl.com/node-webshot" @xan_z
    – FabricioG
    Nov 7 at 19:46















up vote
0
down vote

favorite












I currently have an express server I'm running based on the express tutorial.



Here is my code for server.js



const express = require('express')
const app = express()
const port = 3000

app.get('/', (req, res) => res.send('Hello World!'))

app.listen(port, () => console.log(`Example app listening on port ${port}!`))


the server.js file is in a directory on my server:



http://myurl.com/node-webshot/server.js


I start the server with: npm start
and get this:



> webshot@0.18.0 start /home/myurl/node-webshot
> node server.js

Example app listening on port 3000!


when I go to my url: http://myserver.com/node-webshot/
I see the directory listing only:
enter image description here



note "myserver.com" is just a fill in to path for working folder.



My expected result would be that when I go to the roof of the file where server.js is loaded that it would show the "Hello world". Not sure what I'm missing here.










share|improve this question






















  • simply go to http://<serverName>:port/
    – xan_z
    Nov 7 at 18:56










  • Cannot GET /preview/productpreview/node-webshot @xan_z
    – FabricioG
    Nov 7 at 19:04










  • I see your comment works, not url where I was pointing to. Since I placed server.js file in specific folder I was calling that route. @xan_z
    – FabricioG
    Nov 7 at 19:06










  • you don't call your server side files/code - they are served by the server based on the routes you have. - and hence you invoke the routes based on the server IP/DNS and port - followed by the route - as you have only one get route of '/' - that is the only thing which can be done with the above code for now.
    – xan_z
    Nov 7 at 19:11










  • Is there anyway to expose the url path with out using a port? For example I'd like to just go to the url like this "myurl.com/node-webshot" @xan_z
    – FabricioG
    Nov 7 at 19:46













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I currently have an express server I'm running based on the express tutorial.



Here is my code for server.js



const express = require('express')
const app = express()
const port = 3000

app.get('/', (req, res) => res.send('Hello World!'))

app.listen(port, () => console.log(`Example app listening on port ${port}!`))


the server.js file is in a directory on my server:



http://myurl.com/node-webshot/server.js


I start the server with: npm start
and get this:



> webshot@0.18.0 start /home/myurl/node-webshot
> node server.js

Example app listening on port 3000!


when I go to my url: http://myserver.com/node-webshot/
I see the directory listing only:
enter image description here



note "myserver.com" is just a fill in to path for working folder.



My expected result would be that when I go to the roof of the file where server.js is loaded that it would show the "Hello world". Not sure what I'm missing here.










share|improve this question













I currently have an express server I'm running based on the express tutorial.



Here is my code for server.js



const express = require('express')
const app = express()
const port = 3000

app.get('/', (req, res) => res.send('Hello World!'))

app.listen(port, () => console.log(`Example app listening on port ${port}!`))


the server.js file is in a directory on my server:



http://myurl.com/node-webshot/server.js


I start the server with: npm start
and get this:



> webshot@0.18.0 start /home/myurl/node-webshot
> node server.js

Example app listening on port 3000!


when I go to my url: http://myserver.com/node-webshot/
I see the directory listing only:
enter image description here



note "myserver.com" is just a fill in to path for working folder.



My expected result would be that when I go to the roof of the file where server.js is loaded that it would show the "Hello world". Not sure what I'm missing here.







node.js express






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 7 at 18:52









FabricioG

316314




316314












  • simply go to http://<serverName>:port/
    – xan_z
    Nov 7 at 18:56










  • Cannot GET /preview/productpreview/node-webshot @xan_z
    – FabricioG
    Nov 7 at 19:04










  • I see your comment works, not url where I was pointing to. Since I placed server.js file in specific folder I was calling that route. @xan_z
    – FabricioG
    Nov 7 at 19:06










  • you don't call your server side files/code - they are served by the server based on the routes you have. - and hence you invoke the routes based on the server IP/DNS and port - followed by the route - as you have only one get route of '/' - that is the only thing which can be done with the above code for now.
    – xan_z
    Nov 7 at 19:11










  • Is there anyway to expose the url path with out using a port? For example I'd like to just go to the url like this "myurl.com/node-webshot" @xan_z
    – FabricioG
    Nov 7 at 19:46


















  • simply go to http://<serverName>:port/
    – xan_z
    Nov 7 at 18:56










  • Cannot GET /preview/productpreview/node-webshot @xan_z
    – FabricioG
    Nov 7 at 19:04










  • I see your comment works, not url where I was pointing to. Since I placed server.js file in specific folder I was calling that route. @xan_z
    – FabricioG
    Nov 7 at 19:06










  • you don't call your server side files/code - they are served by the server based on the routes you have. - and hence you invoke the routes based on the server IP/DNS and port - followed by the route - as you have only one get route of '/' - that is the only thing which can be done with the above code for now.
    – xan_z
    Nov 7 at 19:11










  • Is there anyway to expose the url path with out using a port? For example I'd like to just go to the url like this "myurl.com/node-webshot" @xan_z
    – FabricioG
    Nov 7 at 19:46
















simply go to http://<serverName>:port/
– xan_z
Nov 7 at 18:56




simply go to http://<serverName>:port/
– xan_z
Nov 7 at 18:56












Cannot GET /preview/productpreview/node-webshot @xan_z
– FabricioG
Nov 7 at 19:04




Cannot GET /preview/productpreview/node-webshot @xan_z
– FabricioG
Nov 7 at 19:04












I see your comment works, not url where I was pointing to. Since I placed server.js file in specific folder I was calling that route. @xan_z
– FabricioG
Nov 7 at 19:06




I see your comment works, not url where I was pointing to. Since I placed server.js file in specific folder I was calling that route. @xan_z
– FabricioG
Nov 7 at 19:06












you don't call your server side files/code - they are served by the server based on the routes you have. - and hence you invoke the routes based on the server IP/DNS and port - followed by the route - as you have only one get route of '/' - that is the only thing which can be done with the above code for now.
– xan_z
Nov 7 at 19:11




you don't call your server side files/code - they are served by the server based on the routes you have. - and hence you invoke the routes based on the server IP/DNS and port - followed by the route - as you have only one get route of '/' - that is the only thing which can be done with the above code for now.
– xan_z
Nov 7 at 19:11












Is there anyway to expose the url path with out using a port? For example I'd like to just go to the url like this "myurl.com/node-webshot" @xan_z
– FabricioG
Nov 7 at 19:46




Is there anyway to expose the url path with out using a port? For example I'd like to just go to the url like this "myurl.com/node-webshot" @xan_z
– FabricioG
Nov 7 at 19:46

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53195956%2fexpress-not-loading-in-url%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53195956%2fexpress-not-loading-in-url%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

Academy of Television Arts & Sciences

L'Équipe

1995 France bombings