Skip to content

Instantly share code, notes, and snippets.

@zwhitchcox
Last active March 22, 2017 05:26
Show Gist options
  • Select an option

  • Save zwhitchcox/b1e79e3e3cdd3376e8d7fa33c317b9d3 to your computer and use it in GitHub Desktop.

Select an option

Save zwhitchcox/b1e79e3e3cdd3376e8d7fa33c317b9d3 to your computer and use it in GitHub Desktop.
const express = require('express')
const http = require('http')
const Gun = require('gun')
const app = express()
const server = http.createServer(app)
Gun({file: 'data.json', web: app})
app.use(Gun.serve)
app.get('/', function (req, res) {
res.end(`
<!doctype html>
<html>
<head>
<title>Gun - React Examples</title>
</head>
<body>
<script src="http://rawgit.com/amark/gun/master/gun.js"></script>
<script>
var gun = Gun(location.origin+'/gun')
var todos = gun.get('todos')
todos.on(function(todos){console.log(todos)})
</script>
</body>
</html>
`)})
server.listen(4000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment