Server with basic example (gun in action) - amark/gun GitHub Wiki

Start a new repo:

// server.js

;(function(){
  var gun = require('gun/examples/http');
  if(!gun.back){ return } // http example auto spawns subprocess

  var fs = require('fs');
  var server = gun.back('opt.web');
  var route = server.route = {}

  fs.readdir('./route', function(err, dir){
      if(err || !dir){ return }
      dir.forEach(function(file){
          if(!file){ return }
          route[file.split('.')[0]] = require('./route/'+file);
      });
  });
 
// with this line you can type a message on http://localhost:8765/basic/paste.html and check if the server works.
  gun.get('test').on(data => console.log(data))

}());

-npm gun

-npm start

Check if the server works

image image

⚠️ **GitHub.com Fallback** ⚠️