Re: how to get dynamic pages?

Rainer Joswig <[email protected]> Mon, 20 Jun 2011 10:11:40 +0200
Newsgroups gmane.lisp.cl-http
Message-ID <[email protected]>
--===============2983520047276840971==
Content-Type: multipart/alternative; boundary="Apple-Mail=_0983C190-DF66-4AE2-9A16-B1ED33E2AE10"


--Apple-Mail=_0983C190-DF66-4AE2-9A16-B1ED33E2AE10
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
	charset=iso-8859-1


Am 20.06.2011 um 04:25 schrieb Changxue.Yang:

> Hello! everyone.=20
>=20
> 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.

You have exported  http://winslin.com:8000/test.html

> the aphorism result never change. I do not know why it do not work.=20
> what I have to do then get dynamic pages?

Your example works for me.

>=20
>=20
>=20
> code as follow:
>=20
> (in-package :HTTP-USER)
>=20
> (defparameter *version* 0)
> (defparameter *last-fetch* 0)
>=20
> (defun random-elt (list)=20
>   (elt list (random (length list))))
>=20
> (defun aphorism (stream)
>   "write a random aphorism to stream."
>   (format stream "~a ~a." (random-elt
> 						   '("Many hands make"=20=

> 							 "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"=20
> 						"the root of all =
evil"))))
>=20
> (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.=20
> 		  (setq *last-fetch* now)
> 		  (note-anchor "Update" :reference "/test.html" :stream =
stream))))))
>=20
> (export-url #u("/test.html" :host "wislin.com" :port 8000)
> 			:computed
> 			:response-function 'display-test-page
> 			:expiration `(:NO-EXPIRATION-HEADER))
>=20
> wislin
> _______________________________________________
> WWW-CL mailing list
> [email protected]
> https://lists.csail.mit.edu/mailman/listinfo/www-cl


--Apple-Mail=_0983C190-DF66-4AE2-9A16-B1ED33E2AE10
Content-Transfer-Encoding: 7bit
Content-Type: text/html;
	charset=iso-8859-1

<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>Am 20.06.2011 um 04:25 schrieb Changxue.Yang:</div><br class="Apple-interchange-newline"><blockquote type="cite"><span class="Apple-style-span" style="border-collapse: collapse; font-family: arial, sans-serif; font-size: 13px; "><span style="border-collapse: collapse; font-family: arial, sans-serif; font-size: 13px; "><div>Hello! everyone.&nbsp;</div>
<div><br></div><div>I'm learning &nbsp;cl-http, and test a example as follow.</div></span><span style="border-collapse: collapse; font-family: arial, sans-serif; font-size: 13px; "><div><span style="border-collapse: collapse; font-family: arial, sans-serif; font-size: 13px; ">when I test aphorism function in repl, It's work.</span></div>
</span><span style="border-collapse: collapse; font-family: arial, sans-serif; font-size: 13px; "><div><span style="border-collapse: collapse; font-family: arial, sans-serif; font-size: 13px; ">but when open&nbsp;<a href="http://wislin.com/test.html" target="_blank" style="color: rgb(20, 125, 186); ">http://wislin.com/test.html</a>, and refresh.</span></div></span></span></blockquote><div><br></div><div>You have exported &nbsp;<a href="http://winslin.com:8000/test.html">http://winslin.com:8000/test.html</a></div><br><blockquote type="cite"><span class="Apple-style-span" style="border-collapse: collapse; font-family: arial, sans-serif; font-size: 13px; "><span style="border-collapse: collapse; font-family: arial, sans-serif; font-size: 13px; ">
</span><div><font face="arial, sans-serif"><span style="border-collapse: collapse; ">the aphorism result never change.</span></font><span style="border-collapse: collapse; font-family: arial, sans-serif; font-size: 13px; ">&nbsp;I do not know why it do not work.&nbsp;</span></div>
<div><font face="arial, sans-serif"><span style="border-collapse: collapse; ">what I have to do then get dynamic pages?</span></font></div></span></blockquote><div><br></div><div>Your example works for me.</div><br><blockquote type="cite"><span class="Apple-style-span" style="border-collapse: collapse; font-family: arial, sans-serif; font-size: 13px; "><div><font face="arial, sans-serif"><span style="border-collapse: collapse; "><br>
</span></font></div><div><span style="border-collapse: collapse; font-family: 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 *last-fetch* 0)</div><div style="color: rgb(80, 0, 80); "><div><br></div><div>(defun random-elt (list)&nbsp;</div><div>&nbsp; (elt list (random (length list))))</div>
<div><br></div><div>(defun aphorism (stream)</div><div>&nbsp; "write a random aphorism to stream."</div><div>&nbsp; (format stream "~a ~a." (random-elt</div><div><span style="white-space: pre-wrap; ">						</span>&nbsp;&nbsp; '("Many hands make"&nbsp;</div>
<div><span style="white-space: pre-wrap; ">							</span>&nbsp;"Too many cooks spoil"</div><div><span style="white-space: pre-wrap; ">							</span>&nbsp;"A stitch in time saves"</div><div><span style="white-space: pre-wrap; ">							</span>&nbsp;"All work and no play makes"</div>
<div><span style="white-space: pre-wrap; ">							</span>&nbsp;"Money is"))</div><div><span style="white-space: pre-wrap; ">		</span>&nbsp;&nbsp;(random-elt '("light work" "the broth" "nine" "Jack a dull boy"&nbsp;</div>
</div><div><span style="white-space: pre-wrap; ">						</span>"the root of all evil"))))</div><div><br></div><div>(defun display-test-page (url stream)</div><div>&nbsp; "Routine to test export options."</div>
<div>&nbsp; (let ((title "Test page")</div><div><span style="white-space: pre-wrap; ">		</span>(now (get-universal-time)))</div><div><span style="white-space: pre-wrap; ">	</span>(with-successful-response (stream :html :expires (expiration-universal-time url))</div>
<div><span style="white-space: pre-wrap; ">	</span>&nbsp;&nbsp;(with-html-document (:declare-dtd-version-p :transitional :stream stream)</div><div style="color: rgb(80, 0, 80); "><div><span style="white-space: pre-wrap; ">		</span>(with-document-preamble (:stream stream)</div>
<div><span style="white-space: pre-wrap; ">		</span>&nbsp;&nbsp;(declare-title title :stream stream))</div><div><span style="white-space: pre-wrap; ">		</span>(with-document-body (:stream stream)</div><div><span style="white-space: pre-wrap; ">		</span>&nbsp;&nbsp;(with-section-heading (title :stream stream)</div>
</div><div><span style="white-space: pre-wrap; ">			</span><b>(with-paragraph (:stream stream)</b></div><div><b><span style="white-space: pre-wrap; ">			</span>&nbsp;&nbsp;(format stream "Version: ~a. Time since last version ~a secs"</b></div>
<div><b><span style="white-space: pre-wrap; ">					</span>&nbsp;&nbsp;(incf *version*) (- now *last-fetch*))) ;;here working</b></div><div><span style="white-space: pre-wrap; ">			</span><b>(with-paragraph (:stream stream)</b></div>
<div><b><span style="white-space: pre-wrap; ">			</span>&nbsp;&nbsp;(aphorism stream))) ;; not working, the result never change.&nbsp;</b></div><div><span style="white-space: pre-wrap; ">		</span>&nbsp;&nbsp;(setq *last-fetch* now)</div><div><span style="white-space: pre-wrap; ">		</span>&nbsp;&nbsp;(note-anchor "Update" :reference "/test.html" :stream stream))))))</div>
<div><br></div><div>(export-url #u("/test.html" :host "<a href="http://wislin.com/" target="_blank" style="color: rgb(20, 125, 186); ">wislin.com</a>" :port 8000)</div><div><span style="white-space: pre-wrap; ">			</span>:computed</div>
<div><span style="white-space: pre-wrap; ">			</span>:response-function 'display-test-page</div><div><span style="white-space: pre-wrap; ">			</span>:expiration `(:NO-EXPIRATION-HEADER))</div></div><div><br></div><div>
wislin</div></span></div></span>
_______________________________________________<br>WWW-CL mailing list<br><a href="mailto:[email protected]">[email protected]</a><br>https://lists.csail.mit.edu/mailman/listinfo/www-cl<br></blockquote></div><br></body></html>
--Apple-Mail=_0983C190-DF66-4AE2-9A16-B1ED33E2AE10--


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

--===============2983520047276840971==--