Skip to content

Instantly share code, notes, and snippets.

@ahrjarrett
Last active April 3, 2020 15:34
Show Gist options
  • Select an option

  • Save ahrjarrett/2f4d9aa25a9dd3f4437c6e1ab5d7217e to your computer and use it in GitHub Desktop.

Select an option

Save ahrjarrett/2f4d9aa25a9dd3f4437c6e1ab5d7217e to your computer and use it in GitHub Desktop.
deno uses url protocol to run files. so a gist can double as a TS executable
import { listenAndServe } from 'https://deno.land/std/http/server.ts'
const body: string = `
🥭🥭🥭🥭🥭🥭🥭🥭🥭🥭🥭🥭🥭🥭🥭🥭🥭🥭🥭🥭
🌴🌴🌴 I'M ALLERGIC TO MANGOS 🌴🌴🌴
🥭🥭🥭🥭🥭🥭🥭🥭🥭🥭🥭🥭🥭🥭🥭🥭🥭🥭🥭🥭
`
const options = { port: 8000 };
listenAndServe(options, (req) => {
console.log('incoming request')
console.log(
'hostname', Deno.hostname(),
'loadavg', Deno.loadavg(),
'env', Deno.env(),
'dir<(home)>', Deno.dir('home'),
'font dir', Deno.dir('font'),
Deno.execPath())
//console.log(req)
req.respond({ body });
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment