app.nim 356 B

123456789101112
  1. import prologue, json
  2. proc handlePlaintext*(ctx: Context) {.async.} =
  3. resp plainTextResponse "Hello, World!"
  4. proc handleJson*(ctx: Context) {.async.} =
  5. resp jsonResponse %*{"message": "Hello, World!"}
  6. var app = newApp(settings = newSettings(debug = false))
  7. app.addRoute("/plaintext", handlePlaintext)
  8. app.addRoute("/json", handleJson)
  9. app.run()