0

I am using angular on the front end and express js MongoDB on the backend, in server.js file of express application I am listening on port 3000

    var server = app.listen(3000, function () {
    console.log('Server listening at http://' + server.address().address + ':' + server.address().port);
});

What I want is when I hit localhost:3000 my HTML page in angular js application should get render, which I achieved using

     app.get('/', function (req, res) {
                res.sendfile(__dirname + '/app/userlogin/userlogin.html');
});

When I hit localhost:3000 my HTML page is getting render but it is not including bootstrap files I am getting error 404 for scripts and links which I am adding in head tag but intelligence of vs2015 providing those bootstrap script files when I am trying to add them in my HTML, Following is my project structure and I have placed my bootstrap js and CSS files respectively in app -> js and app -> CSS

enter image description here

1 Answer 1

2

You need a public_static folder containing all your frontend code. The express app should serve it with express.static('')

server.js

app.use(express.static('public_static'));

Directory Structure

-- server.js
-- public_static
           -- index.html ( Rename your userlogin.html )
           -- css
           -- JS ( Angular files )
                --- controllers
                --- directives
                --- services 
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.