Skip to content

Instantly share code, notes, and snippets.

@honewatson
Created October 3, 2016 00:29
Show Gist options
  • Select an option

  • Save honewatson/9e6e49427ef1731bc410df31642d5114 to your computer and use it in GitHub Desktop.

Select an option

Save honewatson/9e6e49427ef1731bc410df31642d5114 to your computer and use it in GitHub Desktop.
JSON Response Nim AsyncHttpServer
import asynchttpserver, asyncdispatch
import json
import cgi
var server = newAsyncHttpServer()
proc handler(req: Request) {.async.} =
let msg = %* {"message": "hello world"}
await req.respond(Http200, $msg, newHttpHeaders([("Content-Type","application/json")]))
waitFor server.serve(Port(8086), handler)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment