Created
October 3, 2016 00:29
-
-
Save honewatson/9e6e49427ef1731bc410df31642d5114 to your computer and use it in GitHub Desktop.
JSON Response Nim AsyncHttpServer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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