lwhttp

Friendly embedded web server based on the lwip TCP/IP stack for the Raspberry Pi Pico W


Keywords
web, http, server, embedded, pico, raspberrypi
License
MIT
Install
nimble install lwhttp

Documentation

lwhttp

A friendly embedded web server for the Raspberry Pi Pico W, based on the lwip TCP/IP stack. Pairs with picostdlib.

Getting started

Set up a pico W project with piconim, then:

import picostdlib/[gpio, time, cyw43]
import lwhttp

proc requested(r: Request, httpMethod: HttpMethod, path: string) =
  case $httpMethod & " " & path
  of "GET /":
    r.respond(Http200, "hello from the pico")
  else:
    r.respond(Http404, $Http404)

startHttp(requested, 80)

respond takes an optional headers argument if you need cookies or content types:

r.respond(Http200, body, newHttpHeaders([("Content-Type", "text/plain")]))

License

MIT