Your First Web Server
Every web application starts with a server. In Clean Language you declare your routes with a simple, readable syntax — and the Frame framework handles compilation, routing, and everything else.
Part of: Frame framework
A Clean Language server has two parts: the plugins it uses and the endpoints it exposes.
plugins:
frame.server
endpoints server:
GET "/" :
return http.respond(200, "text/plain", "Hello, World!")
GET "/about" :
return http.respond(200, "text/plain", "About this server")$ curl localhost:3000/
Hello, World!
$ curl localhost:3000/about
About this serverThe plugins: block tells Clean Language which framework modules to load. endpoints server: declares your HTTP routes. Each route is a method + path. http.respond(status, contentType, body) sends the response.
Save the file as server.cln and start it with cln serve:
cln serve server.clnStarting server on http://0.0.0.0:3000cln serve compiles your file and starts a development server. Open http://localhost:3000 in your browser to see Hello, World! — no build step, no config, no boilerplate.
- plugins: declares which framework modules your server needs
- endpoints server: defines your HTTP routes
- http.respond(status, contentType, body) — status 200 means success
- cln serve server.cln compiles and starts your server in one step