XDPXI's Documentation
HTTP

Route Management

Required version: Sponge >=1.0.5

http.page(path, content)

Registers a route and associates it with content to be served when that path is requested.

Parameters:

  • path (string) - The URL path (e.g., "/", "/about", "/api/users")
  • content (string) - The content to serve (HTML, plain text, JSON, etc.)

Returns: null

Example:

http.page("/", "<h1>Home</h1>");
http.page("/about", "<h1>About Us</h1>");
http.page("/contact", "<h1>Contact</h1>");

http.serve(port)

Starts the HTTP server and begins listening for incoming connections. This function blocks execution.

Parameters:

  • port (number) - The port number to listen on (e.g., 5000, 8080, 3000)

Returns: null

Example:

http.serve(5000);