localhost:3000/index.html (静的ページを配置する場所)、localhost:3000/javascripts/dio.js (js を配置する場所) localhost:3000/images/dio1.jpg (画像を配置する場所)、すべてアクセスできません。なんで?なにが問題ですか?
私の app.js 定義:
var express = require('express')
var app=express()
app.bcrypt = require('bcrypt')
app.im=require('imagemagick')
app.fs=require('fs')
app.application_root = __dirname
app.path = require("path")
app.mongoose = require("mongoose")
var config=require('./config.js')(app,express)
var models = require('./models/models.js')(app.mongoose)
models.UserModel = models.UserModel
models.CommentModel = models.CommentModel
models.ItemModel = models.ItemModel
require('./routes')(app, models)
app.listen(3000);
console.log("Listening on port 3000")
これが私のconfig.js定義です:
module.exports = function(app, express, mongoose){
var config=this
app.configure(function (){
app.set('views',__dirname+'/views')
app.set('view engine','jade')
app.set('view engine', {layout:true})
app.use(express.bodyParser())
app.use(express.methodOverride())
app.use(express.cookieParser())
app.use(express.session({secret: 'topsecret',store: new express.session.MemoryStore}))
app.use(app.router)
app.use(express.static(app.path.join(app.application_root+"public")))
app.use(express.errorHandler({dumpExceptions:true,showStack:true}))
app.use(express.bodyParser({keepExtensions: true, uploadDir:"./public/uploads"}))
})
/*DB part:*/
app.mongoose.connect('mongodb://localhost/dio_database')
return config
}