Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Add cache-control to the self.tcl example script. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
b1545db25bcbaf59f2dfdc3e6514aff0 |
User & Date: | drh 2018-02-08 01:31:17.909 |
Context
2018-02-08
| ||
02:07 | Add the self2.tcl example script (check-in: 0afcafe89f user: drh tags: trunk) | |
01:31 | Add cache-control to the self.tcl example script. (check-in: b1545db25b user: drh tags: trunk) | |
01:24 | Add the "self.tcl" example application that displays a copy of itself. (check-in: 8f65cebe60 user: drh tags: trunk) | |
Changes
Changes to examples/README.md.
︙ | ︙ | |||
58 59 60 61 62 63 64 | want to modify the script to set the DBFILE variable to the correct database name. The password for the "shoplist-demo.db" database is "12345". When the app is running, the /env page shows the CGI environment for debugging and testing purposes. | > > > > > > > > > | 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | want to modify the script to set the DBFILE variable to the correct database name. The password for the "shoplist-demo.db" database is "12345". When the app is running, the /env page shows the CGI environment for debugging and testing purposes. 5.0 self.tcl ------------ This script gives an example of a Wapp application that can display a copy of itself. The self-display in the /self page is actually a very small part of the total script. This example also includes some cache-control and CSS as a demonstration of how that kind of thing is accomplished. |
Changes to examples/self.tcl.
1 2 3 4 5 6 7 8 | # This script demonstrates a Wapp application that can display a copy # of itself via the /self page. (See the wapp-page-self procedure for # how that one page is generated.) # # This script also has a homepage and an /env page that show the wapp # environment. The header and footer for each page is broken out into # separate subroutines. # | | > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | # This script demonstrates a Wapp application that can display a copy # of itself via the /self page. (See the wapp-page-self procedure for # how that one page is generated.) # # This script also has a homepage and an /env page that show the wapp # environment. The header and footer for each page is broken out into # separate subroutines. # # Just for grins, there is also a style-sheet and some cache-control # lines to show how those things work. # package require wapp proc common-header {} { wapp-trim { <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
︙ | ︙ | |||
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | proc common-footer {} { wapp-trim { </body> </html> } } proc wapp-default {} { common-header wapp-trim { <h1>Wapp Self-Display Demo</h1> <ul> <li> <a href='%url([wapp-param SCRIPT_NAME])/self'>Show the script that generates this page</a> <li> <a href='%url([wapp-param SCRIPT_NAME])/env'>Wapp Environment</a> </ol> } common-footer } proc wapp-page-env {} { common-header wapp-trim { <h1>Wapp Environment</h1> <pre>%html([wapp-debug-env])</pre> } common-footer } proc wapp-page-self {} { common-header set fd [open [wapp-param SCRIPT_FILENAME] rb] set script [read $fd] close $fd wapp-trim { <h1>Wapp Script That Shows A Copy Of Itself</h1> <pre>%html($script)</pre> } common-footer } proc wapp-page-style.css {} { wapp-mimetype text/css wapp-trim { pre { border: 1px solid black; padding: 1ex; } } } wapp-start $argv | > > > | 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | proc common-footer {} { wapp-trim { </body> </html> } } proc wapp-default {} { wapp-cache-control max-age=3600 common-header wapp-trim { <h1>Wapp Self-Display Demo</h1> <ul> <li> <a href='%url([wapp-param SCRIPT_NAME])/self'>Show the script that generates this page</a> <li> <a href='%url([wapp-param SCRIPT_NAME])/env'>Wapp Environment</a> </ol> } common-footer } proc wapp-page-env {} { common-header wapp-trim { <h1>Wapp Environment</h1> <pre>%html([wapp-debug-env])</pre> } common-footer } proc wapp-page-self {} { wapp-cache-control max-age=3600 common-header set fd [open [wapp-param SCRIPT_FILENAME] rb] set script [read $fd] close $fd wapp-trim { <h1>Wapp Script That Shows A Copy Of Itself</h1> <pre>%html($script)</pre> } common-footer } proc wapp-page-style.css {} { wapp-mimetype text/css wapp-cache-control max-age=3600 wapp-trim { pre { border: 1px solid black; padding: 1ex; } } } wapp-start $argv |