express

Node.js and express : Routes

扶醉桌前 提交于 2020-01-11 11:42:49
问题 I have some trouble using the router from Express. I want to set up my routes with several files. I get my routes folder with 2 files: routes.js and inscription.js I do the following var inscription = require('./routes/inscription.js'); var routes = require('./routes/routes.js'); Then app.use('/', routes); app.use('/inscription', inscription); But only the routes from routes.js work... This is the content of routes.js var router = require('express').Router(); var bodyParser = require('body

Link to static files from Jade template rendered from a sub route

南笙酒味 提交于 2020-01-11 10:54:25
问题 I have a very basic problem with Node.js/Express/Jade that's surprisingly hard to describe. In my node.js application I use the Express framework for routing of HTTP requests. I also use Jade templates as views, who themselves link to files (css, js etc.) inside a directory that I have declared as static through the app.use(express.static(__dirname + '/public')); command. When I route requests to resources like /about or /contact everything works as expected. But I found that as soon as my

Mongoose Not Saving Data

走远了吗. 提交于 2020-01-11 05:48:06
问题 I am having trouble with a simple query on my database. Following this tutorial: https://scotch.io/tutorials/build-a-restful-api-using-node-and-express-4 when Model.find() is called, he receives a JSON object back with the name field (the only custom field) and the _id and __v. When I do the same, all I receive back is the _id and __v field. I do get a successful response back saying the post was created, but it doesn't include the title or content fields. Yet a query shows that the data was

Can an iisnode-hosted web application work out the virtual path at which it is hosted?

爱⌒轻易说出口 提交于 2020-01-11 05:17:06
问题 I am using iisnode to host a node web application in IIS on Windows. When I set up my routes on the web server (say Express or Restify) I want do do it in a way that is independent of the path that IIS is hosting the application at. For example, my application could be hosted at two different paths on two machines running IIS; the first could host it at /foo and the second at /bar . Say my application wants to set up a route at /baz - on the first machine I would need to configure the route

Backbone Router : Get rid of # in the URL

南笙酒味 提交于 2020-01-11 04:16:08
问题 I'm getting backbone router to work App.Router = Backbone.Router.extend({ routes: { "todo": "todo" }, todo: function() { alert(1); } }); Backbone.history.start(); This works well when I goto url : domain:port/#/todo I want this to work without # in the URL, I tried putting pushState parameter as mentioned in the documents. Backbone.history.start({pushState: true}); This simply redirects # url to the non hashed one domain:port/#/todo (redirects to ==>) domain:port/todo But when I visit this

Express and URL rewriting | HTML5 history

冷暖自知 提交于 2020-01-11 03:40:05
问题 I'm trying to build a simple server to serve a single HTML page where all the logics are handled by Angular. As far as I'm using the HTML5 history mode I'm able to navigate through standard URLs. Now, to make this work I need to enable URL rewriting. I tried with this bunch of lines and although return always the correct HTML page, the URL vary and does not keep the initial value. For example /popular should load index.html and leave the URL /popular so that the JS logic can load the desired

Nginx + (nodejs, socketio, express) + php site

一笑奈何 提交于 2020-01-11 03:07:48
问题 I'm working on a fully js, HTML5 canvas game and want it to be 'real-time'. Based on my research I find out node.js is an exciting prospect, so I configured it on my ubuntu 12 webserver with socket.io, express etc. I'm a programmer, but just a rookie in the world of webserver backends, that's why I ask for your help. I got confused about the overall system model and want to be clarified how it's working. Maybe, I've read too much article in a short time. First of all: I run nginx 1.2.x on my

how to download pdf using NodeJS and send it to the client?

六月ゝ 毕业季﹏ 提交于 2020-01-10 10:03:48
问题 I am trying to download a PDF file using NodeJS then send its data to client to be embedded in the page. Here is how I download the PDF file: exports.sendPdf = function(req, responce) { var donneRecu = req.body; var url = 'http://www.ieee.org/documents/ieeecopyrightform.pdf'//pdf link http.get(url, function(res) { var data = ''; res.on('data', function(chunk) { console.log('downloading'); data += chunk; }); res.on("end", function() { console.log('downloaded'); responce.header("Access-Control

how to download pdf using NodeJS and send it to the client?

不想你离开。 提交于 2020-01-10 10:03:44
问题 I am trying to download a PDF file using NodeJS then send its data to client to be embedded in the page. Here is how I download the PDF file: exports.sendPdf = function(req, responce) { var donneRecu = req.body; var url = 'http://www.ieee.org/documents/ieeecopyrightform.pdf'//pdf link http.get(url, function(res) { var data = ''; res.on('data', function(chunk) { console.log('downloading'); data += chunk; }); res.on("end", function() { console.log('downloaded'); responce.header("Access-Control

how to download pdf using NodeJS and send it to the client?

南楼画角 提交于 2020-01-10 10:02:08
问题 I am trying to download a PDF file using NodeJS then send its data to client to be embedded in the page. Here is how I download the PDF file: exports.sendPdf = function(req, responce) { var donneRecu = req.body; var url = 'http://www.ieee.org/documents/ieeecopyrightform.pdf'//pdf link http.get(url, function(res) { var data = ''; res.on('data', function(chunk) { console.log('downloading'); data += chunk; }); res.on("end", function() { console.log('downloaded'); responce.header("Access-Control