-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHello.psp
More file actions
80 lines (60 loc) · 2.75 KB
/
Copy pathHello.psp
File metadata and controls
80 lines (60 loc) · 2.75 KB
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
<%@ page imports = "sys,os,time"%>
<%@ page method="writeContent" %>
<%@ page extends="ExamplePage"%>
<h1 style="text-align:center;font-family:helvetica,sans-serif;color:blue">Hello from PSP!</h1>
<p>This is a sample page for an implementation of Python Server Pages (PSP).</p>
<p>The syntax for Python Server Pages is almost identical to that of Java Server Pages (JSP).
Just the scripting language is different! And obviously better.
In fact, just about anything you can do with JSP, you can do with PSP, and more.
The only thing the current implementation is missing is Beans, and we'll top that shortly.
In the meantime, with PSP, not only can you create template text that will be inerted
in one method when the page is run as a servlet, but you can choose which base class to inherit from,
you can choose which method of the base class to over-ride with your template text,
and you can add additional methods to the servlet class, all from the PSP template code.</p>
<p>I know, Cool, huh?</p>
<p>The text below comes from another jsp page which was inserted into this one
with the <%@ incude %> directive.</p>
<div style="color:red">
<%@ include file="../../PSP/Examples/my_include.psp" %>
</div>
<p>There are two ways to insert the contents of another file into a PSP page:</p>
<ul>
<li>If you use <%@ include file="somefile" %>, it will effectively
insert the contents of the other file before class creation time.</li>
<li>Using <psp:include page="somefile" /> will insert the file
into the page <em>after</em> page creation. In other words, the file won't be parsed for PSP codes.
It'll just be output as is in the response stream.</li>
</ul>
<div style="color:blue">
<%-- This actually works? <psp:include page = "../../PSP/Examples/APSPinclude.html"> --%>
</div>
<h4>Below is a loop test</h4>
<ul><% for i in range(5): %>
<li>Loop <%= i %><ul><% for j in range(5): %>
<li>Counter 1 is <%= i %> and counter 2 is <%= j %></li>
<% pass %></ul></li>
<% pass %></ul>
<h4>Operating system information</h4>
<p>This works only under Unix:</p>
<table cellspacing="4" cellpadding="4">
<% if hasattr(os, 'uname'):
info = os.uname()
else:
info = (sys.platform, '(node)', '(release)', '(version)', '(machine)')
for i in info:
res.write('<tr><td style="background-color:#CCCCEE;color:#202080">'
+ str(i) + '</td></tr>')
res.write('<tr><td style="background-color:#9999CC;color:#EEEEFF">'
+ req.pathInfo() + '</td></tr>')
%>
</table>
<h4>The time is:</h4>
<%= time.ctime(time.time())%>
<%-- Comment check --%>
<!-- Comment Check -->
<h4>Method call:</h4>
<psp:method name="testing" params="val">
self._response.write('<p>You passed a <strong>%s</strong></p>' % val)
</psp:method>
<%self.testing('value')%>
<% pass %>