Fwd: how to get dynamic pages?

"Changxue.Yang" <[email protected]> Mon, 20 Jun 2011 16:20:12 +0800
Newsgroups gmane.lisp.cl-http
Message-ID <[email protected]>
--===============7491223041089506699==
Content-Type: multipart/alternative; boundary=000325574be280507704a6206756

--000325574be280507704a6206756
Content-Type: text/plain; charset=ISO-8859-1

Hello! everyone.

I'm learning  cl-http, and test a example as follow.
when I test aphorism function in repl, It's work.
but when open http://wislin.com/test.html, and refresh.
the aphorism result never change. I do not know why it do not work.
what I have to do then get dynamic pages?



code as follow:

(in-package :HTTP-USER)

(defparameter *version* 0)
(defparameter *last-fetch* 0)

(defun random-elt (list)
  (elt list (random (length list))))

(defun aphorism (stream)
  "write a random aphorism to stream."
  (format stream "~a ~a." (random-elt
   '("Many hands make"
  "Too many cooks spoil"
 "A stitch in time saves"
 "All work and no play makes"
  "Money is"))
  (random-elt '("light work" "the broth" "nine" "Jack a dull boy"
 "the root of all evil"))))

(defun display-test-page (url stream)
  "Routine to test export options."
  (let ((title "Test page")
(now (get-universal-time)))
(with-successful-response (stream :html :expires (expiration-universal-time
url))
   (with-html-document (:declare-dtd-version-p :transitional :stream stream)
(with-document-preamble (:stream stream)
   (declare-title title :stream stream))
(with-document-body (:stream stream)
  (with-section-heading (title :stream stream)
 *(with-paragraph (:stream stream)*
*   (format stream "Version: ~a. Time since last version ~a secs"*
*   (incf *version*) (- now *last-fetch*))) ;;here working*
*(with-paragraph (:stream stream)*
*   (aphorism stream))) ;; not working, the result never change. *
  (setq *last-fetch* now)
  (note-anchor "Update" :reference "/test.html" :stream stream))))))

(export-url #u("/test.html" :host "wislin.com" :port 8000)
:computed
 :response-function 'display-test-page
:expiration `(:NO-EXPIRATION-HEADER))

wislin

--000325574be280507704a6206756
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<div class=3D"gmail_quote"><br><span style=3D"border-collapse:collapse;font=
-family:arial, sans-serif;font-size:13px"><span style=3D"border-collapse:co=
llapse;font-family:arial, sans-serif;font-size:13px"><div>Hello! everyone.=
=A0</div>

<div><br></div><div>I&#39;m learning =A0cl-http, and test a example as foll=
ow.</div></span><span style=3D"border-collapse:collapse;font-family:arial, =
sans-serif;font-size:13px"><div><span style=3D"border-collapse:collapse;fon=
t-family:arial, sans-serif;font-size:13px">when I test aphorism function in=
 repl, It&#39;s work.</span></div>

</span><span style=3D"border-collapse:collapse;font-family:arial, sans-seri=
f;font-size:13px"><div><span style=3D"border-collapse:collapse;font-family:=
arial, sans-serif;font-size:13px">but when open=A0<a href=3D"http://wislin.=
com/test.html" style=3D"color:rgb(20, 125, 186)" target=3D"_blank">http://w=
islin.com/test.html</a>, and refresh.</span></div>

</span><div><font face=3D"arial, sans-serif"><span style=3D"border-collapse=
:collapse">the aphorism result never change.</span></font><span style=3D"bo=
rder-collapse:collapse;font-family:arial, sans-serif;font-size:13px">=A0I d=
o not know why it do not work.=A0</span></div>

<div><font face=3D"arial, sans-serif"><span style=3D"border-collapse:collap=
se">what I have to do then get dynamic pages?</span></font></div><div><font=
 face=3D"arial, sans-serif"><span style=3D"border-collapse:collapse"><br>
</span></font></div><div><span style=3D"border-collapse:collapse;font-famil=
y:arial, sans-serif;font-size:13px"><div><br></div><div><br></div><div>code=
 as follow:</div><div><br></div><div><div>(in-package :HTTP-USER)</div>
<div><br></div><div>(defparameter *version* 0)</div><div>(defparameter *las=
t-fetch* 0)</div><div style=3D"color:rgb(80, 0, 80)"><div><br></div><div>(d=
efun random-elt (list)=A0</div><div>=A0 (elt list (random (length list))))<=
/div>

<div><br></div><div>(defun aphorism (stream)</div><div>=A0 &quot;write a ra=
ndom aphorism to stream.&quot;</div><div>=A0 (format stream &quot;~a ~a.&qu=
ot; (random-elt</div><div><span style=3D"white-space:pre-wrap">						</span=
>=A0=A0 &#39;(&quot;Many hands make&quot;=A0</div>

<div><span style=3D"white-space:pre-wrap">							</span>=A0&quot;Too many c=
ooks spoil&quot;</div><div><span style=3D"white-space:pre-wrap">							</sp=
an>=A0&quot;A stitch in time saves&quot;</div><div><span style=3D"white-spa=
ce:pre-wrap">							</span>=A0&quot;All work and no play makes&quot;</div>

<div><span style=3D"white-space:pre-wrap">							</span>=A0&quot;Money is&q=
uot;))</div><div><span style=3D"white-space:pre-wrap">		</span>=A0=A0(rando=
m-elt &#39;(&quot;light work&quot; &quot;the broth&quot; &quot;nine&quot; &=
quot;Jack a dull boy&quot;=A0</div>

</div><div><span style=3D"white-space:pre-wrap">						</span>&quot;the root=
 of all evil&quot;))))</div><div><br></div><div>(defun display-test-page (u=
rl stream)</div><div>=A0 &quot;Routine to test export options.&quot;</div>

<div>=A0 (let ((title &quot;Test page&quot;)</div><div><span style=3D"white=
-space:pre-wrap">		</span>(now (get-universal-time)))</div><div><span style=
=3D"white-space:pre-wrap">	</span>(with-successful-response (stream :html :=
expires (expiration-universal-time url))</div>

<div><span style=3D"white-space:pre-wrap">	</span>=A0=A0(with-html-document=
 (:declare-dtd-version-p :transitional :stream stream)</div><div style=3D"c=
olor:rgb(80, 0, 80)"><div><span style=3D"white-space:pre-wrap">		</span>(wi=
th-document-preamble (:stream stream)</div>

<div><span style=3D"white-space:pre-wrap">		</span>=A0=A0(declare-title tit=
le :stream stream))</div><div><span style=3D"white-space:pre-wrap">		</span=
>(with-document-body (:stream stream)</div><div><span style=3D"white-space:=
pre-wrap">		</span>=A0=A0(with-section-heading (title :stream stream)</div>

</div><div><span style=3D"white-space:pre-wrap">			</span><b>(with-paragrap=
h (:stream stream)</b></div><div><b><span style=3D"white-space:pre-wrap">		=
	</span>=A0=A0(format stream &quot;Version: ~a. Time since last version ~a =
secs&quot;</b></div>

<div><b><span style=3D"white-space:pre-wrap">					</span>=A0=A0(incf *versi=
on*) (- now *last-fetch*))) ;;here working</b></div><div><span style=3D"whi=
te-space:pre-wrap">			</span><b>(with-paragraph (:stream stream)</b></div>
<div><b><span style=3D"white-space:pre-wrap">			</span>=A0=A0(aphorism stre=
am))) ;; not working, the result never change.=A0</b></div><div><span style=
=3D"white-space:pre-wrap">		</span>=A0=A0(setq *last-fetch* now)</div><div>=
<span style=3D"white-space:pre-wrap">		</span>=A0=A0(note-anchor &quot;Upda=
te&quot; :reference &quot;/test.html&quot; :stream stream))))))</div>

<div><br></div><div>(export-url #u(&quot;/test.html&quot; :host &quot;<a hr=
ef=3D"http://wislin.com/" style=3D"color:rgb(20, 125, 186)" target=3D"_blan=
k">wislin.com</a>&quot; :port 8000)</div><div><span style=3D"white-space:pr=
e-wrap">			</span>:computed</div>

<div><span style=3D"white-space:pre-wrap">			</span>:response-function &#39=
;display-test-page</div><div><span style=3D"white-space:pre-wrap">			</span=
>:expiration `(:NO-EXPIRATION-HEADER))</div></div><div><br></div><div>
wislin</div></span></div></span>
</div><br><br clear=3D"all"><br>

--000325574be280507704a6206756--


--===============7491223041089506699==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
WWW-CL mailing list
[email protected]
https://lists.csail.mit.edu/mailman/listinfo/www-cl

--===============7491223041089506699==--