Wapp

Check-in [bd84938961]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add the external content demo script.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | trunk
Files: files | file ages | folders
SHA3-256: bd84938961bebe74347093b7766fc68acbfb391d31e8d82260d912f02833570a
User & Date: drh 2020-02-28 21:30:36
Context
2020-02-28
21:30
Add the external content demo script. Leaf check-in: bd84938961 user: drh tags: trunk
2019-10-15
14:54
Fix documentation typos. check-in: 04b1d555cf user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Added examples/externimage.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
95
96
97
98
99
#!/usr/bin/wapptclsh
#
# This script demonstrates how Wapp to return resources (such as
# an image) held in separate files or in a separate SQLite database.
#
package require wapp

# Common header and footer.
proc common-header {} {
  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">
    <link href="%url([wapp-param SCRIPT_NAME]/style.css)" rel="stylesheet">
    <title>Wapp External Content Demo</title>
    </head>
    <body>
  }
}
proc common-footer {} {
  wapp-trim {
    </body>
    </html>
  }
}

# The style sheet
proc wapp-page-style.css {} {
  wapp-mimetype text/css
  wapp-cache-control max-age=3600
  wapp-trim {
    pre {
       border: 1px solid black;
       padding: 1ex;
    }
  }
}

# This is the default page
proc wapp-default {} {
  common-header
  wapp-trim {
    <h1>External Content Demo</h1>
    <p>This demo shows how Wapp can return resources (such as images)
    that are loaded from separate files on disk, or from a separate
    database.  This demo shows two images:

    <p><img src="image1"><br>"plume1"
    <p><img src="image2"><br>"plume2"

    <p>Both images are the same PNG file.  The first image is loaded
    from a separate file on disk.  The second image is loaded form
    an SQLite database.

    <p>Click <a href="self">here</a> to see the complete Wapp script
    that generates this application.
  }
}

# The /self page that returns HTML that displays a copy of this script itself
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>Text Of The External Content Demo Script</h1>
    <pre>%html($script)</pre>
  }
  common-footer
}

# The /image1 image, read from a separate file named "plume.png"
# found in the same directory as this script.
#
proc wapp-page-image1 {} {
  wapp-mimetype image/png
  set filename [file dir [wapp-param SCRIPT_FILENAME]]/plume.png
  set fd [open $filename rb]
  wapp [read $fd]
  close $fd
}

# The /image2 image, read from an SQLite database named "plume.db"
# found in the same directory as this script.
#
proc wapp-page-image2 {} {
  set dbname [file dir [wapp-param SCRIPT_FILENAME]]/plume.db
  sqlite3 db $dbname
  db eval {SELECT data, mimetype FROM image LIMIT 1} break
  wapp-mimetype $mimetype
  wapp $data
  db close
}

# Start Wapp running
wapp-start $argv

Added examples/plume.db.

cannot compute difference between binary files

Added examples/plume.png.

cannot compute difference between binary files