Error to get css in express

438
January 15, 2017, at 03:38 AM

I've been getting the error bellow when I try to reach http://localhost:3000/contato/1

GET http://localhost:3000/contato/static/bootstrap/dist/css/bootstrap.min.css 404 (Not Found)

Which is defined by this route:

app.route('/contato/:id')
    .get(autenticar, contatos.show);

In other routes that doesn't have :id param, the css is rendered fine.

I'm using Pug to develop the pages, and serving static files through public folder, using:

app.use('/static', express.static(__dirname + '/public'));

My header.pug, which I extends in evey page.

doctype html
html
head
    link(href='static/bootstrap/dist/css/bootstrap.min.css' rel='stylesheet')
    meta(charset='utf-8')
    meta(name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no")
    title Ntalk - Agenda de Contatos
body
    div(class='container')
        block content

The route who's getting the error:

show.pug

include ../header
  block content
    div(class='row')
      div(class='col-md-6 offset-md-3')
        section(class='container')
          header
            h2 Ntalk - Dados do contato
Answer 1

You should change the link to the css (by adding / at the start) in the header.pug

link(href='/static/bootstrap/dist/css/bootstrap.min.css' rel='stylesheet')

Otherwise it is relevant to the current page

Rent Charter Buses Company
READ ALSO
Avoiding White Spaces between Html Elements

Avoiding White Spaces between Html Elements

I need to get the following result

273
jQuery function after append element

jQuery function after append element

can somebody tell me, how to append html code,that have button element and make that button functionable? Why my function not working on appended button? Here's my code

403
Expected ';' exception in I.E (JavaScript, jQuery)

Expected ';' exception in I.E (JavaScript, jQuery)

I'm testing my website for IE compatibility and right away I run into plethora of problems:

426
rendering HTML from javascript iteration to print table row not working with TypeError

rendering HTML from javascript iteration to print table row not working with TypeError

Learning from hereI am trying to render HTML of this sensor data:

360