Skip to content

Instantly share code, notes, and snippets.

@jdx
Last active August 11, 2016 23:06
Show Gist options
  • Select an option

  • Save jdx/fae51d1a5e363d8519913bd073d318c4 to your computer and use it in GitHub Desktop.

Select an option

Save jdx/fae51d1a5e363d8519913bd073d318c4 to your computer and use it in GitHub Desktop.
Simple React Basic Fileserver
'use strict'
const koa = require('koa')
const send = require('koa-send')
const path = require('path')
const app = koa()
app.use(require('koa-compress')())
app.use(require('koa-logger')())
app.use(require('koa-static')('public'))
app.use(function * (next) {
if (this.method !== 'GET') return yield next
yield send(this, path.join('public', 'index.html'))
})
app.listen(process.env.PORT || 3000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment