HTTP Server Examples

This directory contains examples of building HTTP servers with Duso.

Quick Start

duso examples/http/server.du

Then visit:

Press Ctrl+C to stop the server gracefully.

Files

How It Works

  1. The main script creates an HTTP server on port 8080
  2. Routes are registered with the handler script paths
  3. server.start() blocks, listening for requests
  4. Each incoming request spawns a fresh script instance
  5. The handler script accesses the request via context() builtin
  6. When Ctrl+C is pressed, the server shuts down gracefully
  7. Cleanup code in the main script runs after shutdown

Key Features Demonstrated

Exploring Further

Try modifying: