Nim: How to build a HTTP server
Mar 21, 2022
Nim uses the Nimble package managet to bundle dependencies (it's included with Nim as of 0.15.0). Using nimble
we can install the prologue
server
$ nimble install prologue
and now implementing a basic web server is not to dissimilar to Sinatra, ExpressJS, or most other minimalist frameworks:
import prologue
proc hello*(ctx: Context) {.async.} =
resp "<h1>Hello World!</h1>"
let app = newApp()
app.get("/", hello)
app.run()
Hi, I'm Glenn! 👋 I'm currently Director of Product (Terraform) @ HashiCorp, and we're hiring! If you'd like to come and work with me and help make Terraform Cloud even more amazing we have multiple positions opening in Product Management, Design, and Engineering & Engineering Management across a range of levels (i.e., junior through to senior). Please send in an application ASAP so we can get in touch.