Skip to content

Instantly share code, notes, and snippets.

@laduke
Created July 10, 2018 17:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save laduke/56a076d304967649ae461375394db633 to your computer and use it in GitHub Desktop.
Save laduke/56a076d304967649ae461375394db633 to your computer and use it in GitHub Desktop.
simple html index
var http = require('http')
var { html, title, head, body, div } = require('hyperaxe')
var page = html(
head(title('hi')),
body(
div({ id: 'app' })
)
).outerHTML
http.createServer(function (req, res) {
res.write(page)
res.end()
}).listen(8899)
@laduke
Copy link
Author

laduke commented Jul 10, 2018

var http = require('http')
var { html, title, head, body, div } = require('hyperaxe')
var fromString = require('from2-string')

var page = html(
  head(title('hi')),
  body(
    div({ id: 'app' })
  )
).outerHTML

http.createServer(function (req, res) {
  fromString(page).pipe(res)
}).listen(8899)

@laduke
Copy link
Author

laduke commented Jul 10, 2018

var http = require('http')
var h = require('hyperscript')
var fromString = require('from2-string')

var page = h(
  'html'
  , h('head'
    , h('title', 'the title'))
  , h('body'
    , h('div', { id: 'app' }))
).outerHTML

http.createServer(function (req, res) {
  fromString(page).pipe(res)
}).listen(8899)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment