Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Add the shoplist.tcl example script. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
351d1c485874ea6a936412f76a53d539 |
User & Date: | drh 2018-01-31 18:52:55.012 |
Context
2018-01-31
| ||
22:15 | Updated shopping list app (check-in: 8526aa6f10 user: drh tags: trunk) | |
18:52 | Add the shoplist.tcl example script. (check-in: 351d1c4858 user: drh tags: trunk) | |
01:09 | Get automatic compression working for CGI. (check-in: 9aa39ada4d user: drh tags: trunk) | |
Changes
Added examples/shoplist.tcl.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 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 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | #!/usr/bin/wapptclsh # # This script implements a simple shopping list. To install: # # (1) Create the database using: # # CREATE TABLE shoplist(id INTEGER PRIMARY KEY AUTOINCREMENT, x TEXT); # CREATE TABLE done(delid INTEGER PRIMARY KEY AUTOINCREMENT, # id INTEGER, x TEXT); # CREATE TABLE config(name TEXT PRIMARY KEY, value ANY) WITHOUT ROWID; # INSERT INTO config VALUES('password',<Your-Password-Here>); # # (2) Edit this script to put the full pathname of the database as the # DBFILE variable # # (3) Make this script a CGI on your server. Or run it in some other # way that Wapp supports. # set DBFILE /shoppinglist.db ;# Change to name of the database. proc wapp-default {} { wapp-trim { <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Shopping List</title> </head><body> <h1>Shopping List</h1> } set self [wapp-param SELF_URL] sqlite3 db $::DBFILE db eval BEGIN if {[wapp-param-exists logout]} { wapp-clear-cookie shopping-list-login set pswd {} } else { set pswd [wapp-param pswd [wapp-param shopping-list-login]] } if {$pswd=="" || ![db exists {SELECT 1 FROM config WHERE name='password' AND value=$pswd}] } { wapp-trim { <p><form method="POST" action="%url($self)"> Password: <input type="password" name="pswd" width=12> <input type="submit" value="Login"></form></p> } db eval COMMIT db close return } if {[wapp-param-exists pswd]} { wapp-set-cookie shopping-list-login $pswd } if {[wapp-param-exists del]} { set id [expr {[wapp-param del]+0}] db eval { INSERT INTO done(id,x) SELECT id, x FROM shoplist WHERE id=$id; DELETE FROM shoplist WHERE id=$id; } } elseif {[wapp-param-exists add]} { set add [wapp-param add] db eval {INSERT INTO shoplist(x) VALUES($add)} } elseif {[wapp-param-exists undel]} { set mx [db one {SELECT max(delid) FROM done}] db eval { INSERT INTO shoplist(id,x) SELECT id, x FROM done WHERE delid=$mx; DELETE FROM done WHERE delid=$mx; } } set cnt 0 db eval {SELECT id, x FROM shoplist ORDER BY id} { if {$cnt} {wapp-subst {<hr>\n}} incr cnt wapp-trim { <p><form method="POST" action="%url($self)"> %html($x) <input type="hidden" name="del" value="%html($id)"> <input type="submit" value="Got It!"></form> } } if {$cnt} {wapp-subst {<hr>\n}} wapp-trim { <p><form method="POST" action="%url($self)"> <input type="text" name="add" width="25"> <input type="submit" value="Add"></form> <hr> <p><form method="POST" action="%url($self)"> <input type="submit" name="undel" value="Undelete"> <input type="submit" name="logout" value="Logout"></form> } db eval COMMIT db close } wapp-start $argv |