javascript - Node.js Express with Azure Bad Request -


i started website on azure , getting bad request errors unknown reason. thing isn't first website , i've encountered before, can't time! maybe i'm tired or something, can me out? following files things i've changed.

server.js

/**  * module dependencies.  */  var express = require('express'); var routes = require('./routes'); var azure = require('azure'); var http = require('http'); var fs = require('fs'); var path = require('path');  var app = express();  var index = require('./routes/index');   app.configure(function(){   app.set('port', process.env.port || 3000);   app.set('views', __dirname + '/views');   app.set('view engine', 'jade');   app.use(express.favicon());   app.use(express.logger('dev'));   app.use(express.bodyparser());   app.use(express.methodoverride());   app.use(app.router);   app.use(express.static(path.join(__dirname, 'public'))); });  app.configure('development', function(){   app.use(express.errorhandler()); });  //routing app.get('/', index.splash); app.get('/thumbnail', index.thumbnail);  //utility app.post('/file-upload', function(req, res) {     // temporary location of file     var tmp_path = req.files.thumbnail.path;     // set file should exists - in case in "images" directory     var target_path = './public/images/' + req.files.thumbnail.name;     // move file temporary location intended location     fs.rename(tmp_path, target_path, function(err) {         if (err) throw err;         // delete temporary file, explicitly set temporary upload dir not filled unwanted files         fs.unlink(tmp_path, function() {             if (err) throw err;             res.send('file uploaded to: ' + target_path + ' - ' + req.files.thumbnail.size + ' bytes');         });     }); });  //no touch http.createserver(app).listen(app.get('port'), function(){   console.log("express server listening on port " + app.get('port')); }); 

thumbnail.jade

h1= title p welcome #{title}  form(method='post', enctype='multipart/form-data', action='/file-upload')     input(type='file', name='thumbnail')     input(type='submit') 

index.js

/*  * home page.  */  exports.index = function(req, res){   res.render('splash', {title: 'express'}); };  exports.thumbnail = function (req, res) {     res.render('thumbnail', { title: 'express' }); };  

i have no idea using webmatrix microsoft ide , express node.js template.

update: getting specific error:

application has thrown uncaught exception , terminated: error: .get() requires callback functions got [object undefined]     @ router.route.route.sensitive (c:\users\shannons\documents\github\circuitsexpress\node_modules\express\lib\router\index.js:252:11)     @ array.foreach (native)     @ router.route (c:\users\shannons\documents\github\circuitsexpress\node_modules\express\lib\router\index.js:248:13)     @ router.methods.foreach.router.(anonymous function) [as get] (c:\users\shannons\documents\github\circuitsexpress\node_modules\express\lib\router\index.js:270:16)     @ function.methods.foreach.app.(anonymous function) [as get] (c:\users\shannons\documents\github\circuitsexpress\node_modules\express\lib\application.js:412:26)     @ object.<anonymous> (c:\users\shannons\documents\github\circuitsexpress\server.js:35:5)     @ module._compile (module.js:449:26)     @ object.module._extensions..js (module.js:467:10)     @ module.load (module.js:356:32)     @ function.module._load (module.js:312:12) 

to sees this, answered own question. yes hexacyanides answer did not answer question still getting bad request errors. did this.

my index.js file untouched. defined new javascript file in routes folder , named roads.js , in server.js file, typed:

var roads =require('./routes/roads');

now of app.get() commands use roads.### in second parameter. may not right solution, works , i've built websites using method before , have turned out fine.


Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -