node app not visible in browser aws ec2
var express = require('express'); var app = express(); app.listen(3000, ()=> { console.log('listening'); }); app.get('/',(req,res)=> { res.send('hi'); });
Here is what the above code is Doing:
1. We’re requiring the express module.
2. We’re creating an express app.
3. We’re telling the app to listen on port 3000.
4. We’re telling the app to respond to a GET request to the root URL (‘/’) with the text ‘hi’.
5. We’re telling the app to respond to a GET request to the /bye URL with the text ‘goodbye’.
6. We’re telling the app to respond to a GET request to any other URL with the text ‘page not found’.