Artifact a05f6626e048cac2f030c06c0184eb2c7650433469c4791c3e85e5d788de0c04:
- File docs/quickref.md — part of check-in [ea88c28347] at 2018-02-07 01:37:30 on branch trunk — New and improved documentation. (user: drh size: 3626)
Wapp Quick Reference
1.0 Interfaces
wapp-start $argv | → | Starts up the Wapp application. Should be last. |
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 | → | Make MIMETYPE the reply mimetype |
wapp-reply-code CODE | → | Set the HTTP reply code to 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 |
2.0 Parameters
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 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 |
WAPP_MODE | → | One of "cgi", "scgi", "server", or "local" |
3.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 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