feat: add example scripts for argparse, bytes, dataset, html, markdown, uuid, wdantic, and web chat modules

Add comprehensive demo scripts showcasing the usage of multiple Wren modules including argument parsing, byte manipulation, in-memory dataset operations, HTML encoding/slugification, markdown-to-HTML conversion, UUID generation/validation, schema validation with wdantic, and a full web chat application with REST endpoints.
This commit is contained in:
2026-01-24 22:40:22 +00:00
parent 0a65272f80
commit 5a4054ec66
105 changed files with 23275 additions and 94 deletions
+19
View File
@@ -0,0 +1,19 @@
// retoor <retoor@molodetz.nl>
import "web" for Response
var r1 = Response.text("Hello")
System.print(r1.body) // expect: Hello
System.print(r1.headers["Content-Type"].contains("text/plain")) // expect: true
var r2 = Response.html("<h1>Hi</h1>")
System.print(r2.body) // expect: <h1>Hi</h1>
System.print(r2.headers["Content-Type"].contains("text/html")) // expect: true
var r3 = Response.json({"name": "test"})
System.print(r3.body.contains("name")) // expect: true
System.print(r3.headers["Content-Type"].contains("application/json")) // expect: true
var r4 = Response.redirect("/login")
System.print(r4.status) // expect: 302
System.print(r4.headers["Location"]) // expect: /login
+21
View File
@@ -0,0 +1,21 @@
// retoor <retoor@molodetz.nl>
import "web" for Router
var router = Router.new()
router.get("/", Fn.new { |r| "home" })
router.get("/users/:id", Fn.new { |r| "user" })
router.post("/api/data", Fn.new { |r| "data" })
var m1 = router.match("GET", "/")
System.print(m1 != null) // expect: true
var m2 = router.match("GET", "/users/123")
System.print(m2 != null) // expect: true
System.print(m2["params"]["id"]) // expect: 123
var m3 = router.match("POST", "/api/data")
System.print(m3 != null) // expect: true
var m4 = router.match("GET", "/notfound")
System.print(m4 == null) // expect: true
+19
View File
@@ -0,0 +1,19 @@
// retoor <retoor@molodetz.nl>
import "web" for SessionStore
var store = SessionStore.new()
var session = store.create()
System.print(session.id != null) // expect: true
System.print(session.id.count) // expect: 36
session["user"] = "alice"
System.print(session["user"]) // expect: alice
store.save(session)
var retrieved = store.get(session.id)
System.print(retrieved != null) // expect: true
System.print(retrieved["user"]) // expect: alice
store.destroy(session.id)
System.print(store.get(session.id) == null) // expect: true