Debian Codegraph @

docs/web/examples/hello.rpy

raw
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}</H1>
25
26 <UL>
27 """.format(
28 now=now
29 )
30
31 for i in range(10):
32 d += "<LI>{i}".format(i=i)
33
34 d += """\
35 </UL>
36
37 </BODY></HTML>
38 """
39
40 data = d.encode("utf8")
41
42 resource = static.Data(data, "text/html")