1.0 Application Template
package require wapp
proc wapp-page-XXXXX {} {
wapp-trim {
# Content to deliver for page XXXXX
}
}
proc wapp-default {} {
wapp-trim {
# Content for all other pages
}
}
wapp-start $argv
2.0 Interfaces
| wapp-start $argv |
→ |
Starts up the Wapp application |
| wapp-subst {TEXT} |
→ |
Append TEXT to the output with substitution |
| wapp-trim {TEXT} |
→ |
Like wapp-subst but also removes left-margin whitespace |
| wapp-param NAME DEFAULT |
→ |
Return value of parameter NAME |
| wapp-set-param NAME VALUE |
→ |
Set parameter NAME to VALUE |
| wapp-param-exists NAME |
→ |
True if parameter NAME exists |
| wapp-param-list GLOB |
→ |
Return parameter names matching GLOB |
| wapp-allow-xorigin-params |
→ |
Allow GET and POST parameters for cross-origin requests |
| wapp-mimetype MIMETYPE |
→ |
Set the reply mimetype |
| wapp-reply-code CODE |
→ |
Set the HTTP reply code |
| wapp-redirect TARGET |
→ |
Redirect to TARGET |
| wapp-reset |
→ |
Reset the output back to an empty string |
| wapp-set-cookie NAME VALUE |
→ |
Set cookie NAME to have VALUE |
| wapp-clear-cookie NAME |
→ |
Delete cookie NAME |
| wapp-cache-control CONTROL |
→ |
Set caching behavior of current page |
| wapp-content-security-policy POLICY |
→ |
Set the CSP for the current page |
| wapp-debug-env |
→ |
Return a text description of the Wapp environment |
| wapp {TEXT} |
→ |
Append TEXT without substitution |
| wapp-unsafe TEXT |
→ |
Append TEXT that contains nothing that needs to be escaped |
| BASE_URL |
→ |
URL for the Wapp script without a method |
| CONTENT |
→ |
Raw (unparsed) POST content |
| CONTENT_LENGTH |
→ |
Number of bytes of raw, unparsed POST content |
| CONTENT_TYPE |
→ |
Mimetype of the POST content |
| DOCUMENT_ROOT |
→ |
Directory that is the root of the webserver content tree |
| HTTP_COOKIE |
→ |
Raw, unparsed cookies |
| HTTP_HOST |
→ |
Hostname to which this request was sent |
| HTTP_USER_AGENT |
→ |
Name of client program that sent current request |
| HTTPS |
→ |
Exists and has value "on" if the request is TLS encrypted |
| PATH_HEAD |
→ |
First element of PATH_INFO. Determines request handler |
| PATH_INFO |
→ |
URL path beyond the application script name |
| PATH_TAIL |
→ |
Part of PATH_INFO beyond PATH_HEAD |
| REMOTE_ADDR |
→ |
IP address of the client |
| REMOTE_PORT |
→ |
TCP port of the client |
| REQUEST_METHOD |
→ |
"GET" or "POST" or "HEAD" |
| SAME_ORIGIN |
→ |
True if this request is from the same origin |
| SCRIPT_FILENAME |
→ |
Full pathname of the Wapp application script |
| SCRIPT_NAME |
→ |
Prefix of PATH_INFO that identifies the application script |
| SELF_URL |
→ |
URL of this request without PATH_TAIL |
| SERVER_ADDR |
→ |
IP address of the webserver sending an SCGI request |
| WAPP_MODE |
→ |
One of "cgi", "scgi", "remote-scgi", "server", or "local" |
4.0 URL Parsing
Assuming "env.tcl" is the name of the Wapp application script:
https://wapp.tcl.tk/demo/env.tcl/abc/def/ghi?a=5&b=22.425#point42
\_________/\___________/\__________/ \__________/
| | | |
HTTP_HOST SCRIPT_NAME PATH_INFO QUERY_STRING
https://wapp.tcl.tk/demo/env.tcl/abc/def/ghi?a=5&b=22.425#point42
\______________________________/ \_/ \_____/
| | |
BASE_URL PATH_HEAD `-- PATH_TAIL
https://wapp.tcl.tk/demo/env.tcl/abc/def/ghi?a=5&b=22.425#point42
\__________________________________/ \__________/
| |
SELF_URL QUERY_STRING
SCRIPT_FILENAME := DOCUMENT_ROOT + SCRIPT_NAME