A talk about using CommonJS modules offline, made at Barcamp Sthlm
Python JavaScript
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
static
templates
.gitignore
Procfile
README.md
auth.py
server.js
site.py
utils.py

README.md

This is an example of how to use Nginx's X-Accel-Redirect to password protect static files, and at the same time use those files as CommonJS modules for a NodeJS server. These files are also added to the cache.manifest to show how to use them offline.

I was a bit lazy when doing this, so this is what you’ll end up with:

  • A flask server (on port 8010)
  • A nginx (on port 9010)
  • A NodeJS server (on port 8020)

The requirements for the python part is flask and requests. The NodeJS server needs ExpressJS. And you need to use the nginx.conf but change the paths to match yours. I use foreman to start it all, so in the ‘Procfile’ you can see what commands is used, or just run ‘foreman start’ and everything is going to be just fine and dandy.