Basic static file server in NodeJS

Less is more Just go command prompt first on your project and use $ npm install express Then write your app.js code like so: var express = require(‘express’), app = express(), port = process.env.PORT || 4000; app.use(express.static(__dirname + ‘/public’)); app.listen(port); You would then create a “public” folder where you place your files. I tried it … Read more

Set subdirectory as website root on Github Pages

There is a detailed gist with all the required steps. The gist is here: https://gist.github.com/cobyism/4730490 From the gist Deploying a subfolder to GitHub Pages Sometimes you want to have a subdirectory on the master branch be the root directory of a repository’s gh-pages branch. This is useful for things like sites developed with Yeoman, or … Read more

http keep-alive in the modern age

Hey since I’m the author of this citation, I’ll respond 🙂 There are two big issues on large sites : concurrent connections and latency. Concurrent connection are caused by slow clients which take ages to download contents, and by idle connection states. Those idle connection states are caused by connection reuse to fetch multiple objects, … Read more

how to configuring a xampp web server for different root directory

You can change Apaches httpd.conf by clicking (in xampp control panel) apache/conf/httpd.conf and adjust the entries for DocumentRoot and the corresponding Directory entry. Just Ctrl+F for “htdocs” and change the entries to your new path. See screenshot: # # DocumentRoot: The directory out of which you will serve your # documents. By default, all requests … Read more

How to enable cross-origin resource sharing (CORS) in the express.js framework on node.js

Check out the example from enable-cors.org: In your ExpressJS app on node.js, do the following with your routes: app.all(“https://stackoverflow.com/”, function(req, res, next) { res.header(“Access-Control-Allow-Origin”, “*”); res.header(“Access-Control-Allow-Headers”, “X-Requested-With”); next(); }); app.get(“https://stackoverflow.com/”, function(req, res, next) { // Handle the get for this route }); app.post(“https://stackoverflow.com/”, function(req, res, next) { // Handle the post for this route }); … Read more

Difference between web server, web container and application server

Your question is similar to below: What is the difference between application server and web server? In Java: Web Container or Servlet Container or Servlet Engine : is used to manage the components like Servlets, JSP. It is a part of the web server. Web Server or HTTP Server: A server which is capable of … Read more