Tekst
Source
Documentation/httpsource tree
Standard library

http

Native HTTP server support built into the runtime. Run the example from a terminal and open http://localhost:8080/.

Routes

get, post, put, and delete register handlers that receive an HTTP request object.

Request values

Handlers can read method, path, query, headers, body, ip, and cookies.

Responses

json(value, status) returns JSON. response(status, body, headers) creates a custom response. redirect(path) returns a 302 redirect.

Middleware and static files

http.use registers middleware. Middleware receives the request and a next callable. http.static(prefix, directory) serves files below a URL prefix.

Serve

serve(port) starts the server and handles requests. The alias server is also available.

server.tk
use http

http.get("/", fn(req) {
    return "Hello from Tekst!"
})

http.get("/api/info", fn(req) {
    return http.json({"language": "Tekst"})
})

http.static("/public", "public")
http.serve(8080)
terminal
tekst server.tk --run