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
+58
View File
@@ -0,0 +1,58 @@
// retoor <retoor@molodetz.nl>
import "web" for Application, Response, View
import "json" for Json
class HelloView is View {
get(request) {
return Response.text("Hello, World!")
}
}
class ApiView is View {
get(request) {
var data = {"message": "API response", "method": "GET"}
return Response.json(data)
}
post(request) {
var body = request.json
var data = {"message": "Data received", "received": body}
return Response.json(data)
}
}
class UserView is View {
get(request) {
var userId = request.params["id"]
return Response.json({"user_id": userId, "action": "get"})
}
}
var app = Application.new()
app.get("/", Fn.new { |req|
return Response.html("<h1>Welcome to Wren Web!</h1><p>A simple web framework.</p>")
})
app.addView("/hello", HelloView)
app.addView("/api", ApiView)
app.addView("/users/:id", UserView)
app.get("/greet/:name", Fn.new { |req|
var name = req.params["name"]
return Response.text("Hello, " + name + "!")
})
app.get("/session", Fn.new { |req|
var count = req.session["count"]
if (count == null) count = 0
count = count + 1
req.session["count"] = count
return Response.json({"visit_count": count})
})
app.static_("/static", "./static")
System.print("Starting server...")
app.run("0.0.0.0", 8080)