how to get dynamic pages?

"Changxue.Yang" <[email protected]> Mon, 20 Jun 2011 10:25:40 +0800
Newsgroups gmane.lisp.cl-http
Message-ID <[email protected]>
--===============2840121209197599584==
Content-Type: multipart/alternative; boundary=90e6ba6e86b293566104a61b73b8

--90e6ba6e86b293566104a61b73b8
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

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

<span class=3D"Apple-style-span" style=3D"border-collapse: collapse; font-f=
amily: arial, sans-serif; font-size: 13px; "><span style=3D"border-collapse=
: collapse; 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: aria=
l, sans-serif; font-size: 13px; "><div><span style=3D"border-collapse: coll=
apse; font-family: arial, sans-serif; font-size: 13px; ">when I test aphori=
sm function in repl, It&#39;s work.</span></div>
</span><span style=3D"border-collapse: collapse; font-family: arial, sans-s=
erif; font-size: 13px; "><div><span style=3D"border-collapse: collapse; fon=
t-family: arial, sans-serif; font-size: 13px; ">but when open=A0<a href=3D"=
http://wislin.com/test.html" target=3D"_blank" style=3D"color: rgb(20, 125,=
 186); ">http://wislin.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=
"border-collapse: collapse; font-family: arial, sans-serif; font-size: 13px=
; ">=A0I do not know why it do not work.=A0</span></div>
<div><font face=3D"arial, sans-serif"><span style=3D"border-collapse: colla=
pse; ">what I have to do then get dynamic pages?</span></font></div><div><f=
ont face=3D"arial, sans-serif"><span style=3D"border-collapse: collapse; ">=
<br>
</span></font></div><div><span style=3D"border-collapse: collapse; font-fam=
ily: arial, sans-serif; font-size: 13px; "><div><br></div><div><br></div><d=
iv>code as follow:</div><div><br></div><div><div>(in-package :HTTP-USER)</d=
iv>
<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=
>(defun 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; ">						</s=
pan>=A0=A0 &#39;(&quot;Many hands make&quot;=A0</div>
<div><span style=3D"white-space: pre-wrap; ">							</span>=A0&quot;Too man=
y cooks spoil&quot;</div><div><span style=3D"white-space: pre-wrap; ">					=
		</span>=A0&quot;A stitch in time saves&quot;</div><div><span style=3D"whi=
te-space: pre-wrap; ">							</span>=A0&quot;All work and no play makes&quo=
t;</div>
<div><span style=3D"white-space: pre-wrap; ">							</span>=A0&quot;Money i=
s&quot;))</div><div><span style=3D"white-space: pre-wrap; ">		</span>=A0=A0=
(random-elt &#39;(&quot;light work&quot; &quot;the broth&quot; &quot;nine&q=
uot; &quot;Jack a dull boy&quot;=A0</div>
</div><div><span style=3D"white-space: pre-wrap; ">						</span>&quot;the r=
oot of all evil&quot;))))</div><div><br></div><div>(defun display-test-page=
 (url stream)</div><div>=A0 &quot;Routine to test export options.&quot;</di=
v>
<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 st=
yle=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-docum=
ent (:declare-dtd-version-p :transitional :stream stream)</div><div style=
=3D"color: rgb(80, 0, 80); "><div><span style=3D"white-space: pre-wrap; ">	=
	</span>(with-document-preamble (:stream stream)</div>
<div><span style=3D"white-space: pre-wrap; ">		</span>=A0=A0(declare-title =
title :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 stre=
am)</div>
</div><div><span style=3D"white-space: pre-wrap; ">			</span><b>(with-parag=
raph (:stream stream)</b></div><div><b><span style=3D"white-space: pre-wrap=
; ">			</span>=A0=A0(format stream &quot;Version: ~a. Time since last versi=
on ~a secs&quot;</b></div>
<div><b><span style=3D"white-space: pre-wrap; ">					</span>=A0=A0(incf *ve=
rsion*) (- now *last-fetch*))) ;;here working</b></div><div><span style=3D"=
white-space: pre-wrap; ">			</span><b>(with-paragraph (:stream stream)</b><=
/div>
<div><b><span style=3D"white-space: pre-wrap; ">			</span>=A0=A0(aphorism s=
tream))) ;; not working, the result never change.=A0</b></div><div><span st=
yle=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;Update&quot; :reference &quot;/test.html&quot; :stream stream))))))</d=
iv>
<div><br></div><div>(export-url #u(&quot;/test.html&quot; :host &quot;<a hr=
ef=3D"http://wislin.com/" target=3D"_blank" style=3D"color: rgb(20, 125, 18=
6); ">wislin.com</a>&quot; :port 8000)</div><div><span style=3D"white-space=
: pre-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>

--90e6ba6e86b293566104a61b73b8--


--===============2840121209197599584==
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

--===============2840121209197599584==--