Node.js and Express handlebars - 404 Error -


for class have design app says @ top of page whether incoming request or post, has print table shows parameter names , values sent in url query string, , property names , values received in request body. far have been able localhost:port work, correctly shows whether request or post. when go subpage supposed display tables, 404 instead.

here render page think causing problem:

function runq(req) {   console.log(req.qparams);   console.log(req.body);    var context = {};   context.queryparams = [];   context.bodyparams = [];   context.querycount = 0;   context.bodycount = 0;    for( var p in req.qparams) {     context.querycount++;     context.queryparams.push({'name': p, 'value': req.qparams[p] });   }    for( var p in req.body) {     context.bodycount++;     context.bodyparams.push({'name': p, 'value': req.body[p] });   }    context.methodtype = req.method;   return context; }  app.get('/request', function(req, res) {   res.render('request', runq(req)); }); app.post('/request', function(req, res) {   res.render('request', runq(req)); }); 

i have request.handlebar saved in ubuntu/getpost/views folder along 404 , 500 handlebars.

the command use testing is:

$ curl --data "a=1&b=2&c=3" localhost:port 

i replaced localhost:port actual ip , port address when have node running. console returns on tab running node:

undefined { a: '1', b: '2', c: '3' } 

and on tab typed curl command:

<!doctype html> <html> <head>         <title>demo page</title> </head> <body>         <h1>post request received</h1>    <table>     <caption><p>request body table</p></caption>     <thead>       <tr>         <th>property names</th>         <th>values</th>       </tr>     </thead>     <tbody>       <tr>         <td>a</td>         <td>1</td>       </tr>       <tr>         <td>b</td>         <td>2</td>       </tr>       <tr>         <td>c</td>         <td>3</td>       </tr>     </tbody>   </table> </body> 

so seems working console when try access localhost:port/request, go 404 error instead of page displays tables.

can tell me i'm doing wrong? thank time.


Comments