未加载样式表,因为找不到node.js的MIME类型和文件

时间:2013-08-26 19:48:18

标签: node.js twitter-bootstrap pug

我正在摆弄使用node.js和jade的twitter bootstrap,但是我没有加载这个样式表因为MIME类型和文件找不到,即使目录是路径是正确的,我猜测我需要“设置“服务器端的路由首先像下面的python的瓶子框架代码

用于python的瓶子框架

@route('/static/js/<filename>')
def js_static(filename):
     return static_file(filename, root='./static/js')

@route('/static/img/<filename>')
def img_static(filename):
    return static_file(filename, root='./static/img')

@route('/static/css/<filename>')  
def img_static(filename):
    return static_file(filename, root='./static/css')

是否有node.js等效?或者,我的玉器设置是否正确?

任何提示都会非常感激

玉文件

!!! 5
html(lang='en')
head
    title title
    link(rel='stylesheet', href='/static/css/bootstrap.css', type='text/css')
  body
    p The open items are as follows:
    table.table.table-striped
      tr
        td "a"
        td "a1"
      tr
        td "b"
        td "b1"
    script(src='/static/js/jquery-2.0.3.min.js')
    script(src='/static/js/bootstrap.js')

bootstrap.js在目录

/static/js/

1 个答案:

答案 0 :(得分:0)

以下是使用CoffeeScriptZappa

的最简单方法

文件结构

├── app.coffee
└─┬ views
  └── index.jade

app.coffee

require('zappa') ->
  @get '/': -> @render 'index'