Initial import to Tizen
[profile/ivi/python-twisted.git] / doc / web / examples / hello.rpy.py
1 # Copyright (c) Twisted Matrix Laboratories.
2 # See LICENSE for details.
3
4 """
5 This is a resource file that renders a static web page.
6
7 To test the script, rename the file to hello.rpy, and move it to any directory,
8 let's say /var/www/html/.
9
10 Now, start your Twisted web server:
11     $ twistd -n web --path /var/www/html/
12
13 And visit http://127.0.0.1:8080/hello.rpy with a web browser.
14 """
15
16 from twisted.web import static
17 import time
18
19 now = time.ctime()
20
21 d = '''\
22 <HTML><HEAD><TITLE>Hello Rpy</TITLE>
23
24 <H1>Hello World, It is Now %(now)s</H1>
25
26 <UL>
27 ''' % vars()
28
29 for i in range(10):
30     d += "<LI>%(i)s" % vars()
31
32 d += '''\
33 </UL>
34
35 </BODY></HTML>
36 '''
37
38 resource = static.Data(d, 'text/html')