Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

multiple "pages" in node.js

multiple "pages" in node.js

Problem

I am using node.js, and my server only has one port open for me to use node.js on. And no, I cannot open more ports. Because I am using this same server for testing and production and it seems like it would be more convenient, I want to be able to have node.js "pages", like in php. Basically, if the url is something, I want the code in one node.js file to be executed. If the url is something else, I want a different node.js script to be run. I want it so that if one page crashes, the rest of the website stays up. I think there might be a way to do this with express, but I'm not sure and I don't know how to do it.

Problem courtesy of: Markasoftware

Solution

You're on the right track with express. You want to use routes within express. Check out:http://expressjs.com/api.html#app.VERB

Also check out: http://elegantcode.com/2012/01/20/taking-toddler-steps-with-node-js-express-routing/

Solution courtesy of: KayakDave

Discussion

View additional discussion.



This post first appeared on Node.js Recipes, please read the originial post: here

Share the post

multiple "pages" in node.js

×

Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription

×