This is a fork of wapp.tcl.tk. The original project is a web framework.
The goal of this fork is to create a universal tool for both, CLI and web scripting in Tcl by adding features that suit that goal.
For more details on changes, check the Github project repository .
The ZipFS binary image has external libraries dependencies, while wapptclsh does not.
$: ./wapptclsh
_ _ _
| | | |___ ___ ___
| | | | .'| . | . |
|_____|__,| _| _|
|_| |_|
Wapp 1.0 shell using SQLite version 3.50.0 and TCL 9.0
% Markdown::convert "# Heading1"
<h1>Heading1</h1>
% datetime "%Y-%m-%d %H:%M:%S" "'now', '+1 day'"
2025-02-21 07:06:50
% datetime "%Y-%m-%d %H:%M:%S" "'now', '+1 day', 'localtime'"
2025-02-21 08:07:13
%
$: ./wapptclsh script.tcl
Hello World!
Implement proc main in the app.tcl and ship it as a single file
$: echo 'proc main {} { puts "All in one" }' >> app.tcl && make
$: ./wapptclsh
All in one
Create first wapplication
$: echo 'proc wapp-default {} { wapp-trim { Hello web! } }; wapp-start $argv' > index.cgi
$: ./wapptclsh index.cgi --server 8082
Listening for HTTP requests on TCP port 8082
$: curl http://localhost:8082
Hello web!
Added to allow you to create "static" variables that retain their values between calls to the procedure.
See: functions.tcl : proc static Added as a minimalist's key-value manager for dict-like lists
See: functions.tcl : proc kv Added to generate a random hexadecimal string using SQLite’s randomblob() for top-notch randomness.
See: functions.tcl : proc randhex Added as a no-nonsense test helper. Takes an expected value—either
a fixed one or a regex wrapped in //. Ditch the bloated test suites.
% test test-1.0 {string match value value} {1}
PASS: test-1.0
% test test-1.1 {string match value value2} {1}
FAIL: test-1.1, want: 1, got: 0 line: 1
% test test-1.2 { set x foo123 } {/foo[0-9]+/}
PASS: test-1.2
% test test-1.3 { set x foo123a } {/foo[0-9]+/}
FAIL: test-1.3, want: foo[0-9]+, got: foo123a line: 1
See: functions.tcl : proc test Added as a replacement for the missing parray command and for convenience.
% parray myArray "ba*"
% parray myArray "*" "value*"
See: functions.tcl : proc parray Added as a replacement for the missing clock command and for convenience.
% datetime "%Y-%m-%d %H:%M:%S" "'now', '+1 day'"
% datetime "%Y-%m-%d" "'now','start of year','+9 months','weekday 2'"
See: functions.tcl : proc datetime Now support setting an expiry time and a secure flag for web applications
wapp-set-cookie session val
wapp-set-cookie session-secure val 0 secure
wapp-set-cookie timed val 3600
wapp-set-cookie timed-secure val 3600 secure
wapp-clear-cookie session
wapp-clear-cookie session-secure "" -1 secure
wapp-clear-cookie timed "" -1
wapp-clear-cookie timed-secure "" -1 secure