Section 2.3. Say Hi (Simple Template)


2.3. Say Hi! (Simple Template)

Okay, now for the obligatory Hello World example. It is really easy, so it won't take more than 30 seconds.

Go to the hello directory within your application path, and to the templates directory within the hello directory, and find the welcome.kid file. Open it up in a text editor (or whatever programming editor you use).

Replace everything inside the <body></body> tags with <h1>Hello World</h1>.

Your welcome.kid file should now look like this:

[View full width]

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR /xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:py="http://purl.org/kid/ns#" py:extends="n'master.kid'"> <head> <meta content="text/html; charset=UTF-8" http-equiv="content-type"py:replace="''"/> <title>Welcome to TurboGears</title> </head> <body> <h1>Hello World</h1> </body> </html>


And when you browse back to http://localhost:8080, you should now see this:

Figure 2.2. Hello from the template


That's it for our basic Hello World program, but let's add a bit of dynamic content to make this more like a real web application.




Rapid Web Applications with TurboGears(c) Using Python to Create Ajax-Powered Sites
Rapid Web Applications with TurboGears: Using Python to Create Ajax-Powered Sites
ISBN: 0132433885
EAN: 2147483647
Year: 2006
Pages: 202

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net