Archive for the ‘Cheetah’ Category
-
Hello, Cheetah World!
Posted on 2月 23rd, 2012 by cx20
Cheetah
Cheetah は Python 用の汎用テンプレートエンジンである。名前の由来は動物のチータから。
ソースコード(テンプレート)
<html> <head> <title>Hello, World!</title> </head> <body> <p>Hello, $message World!</p> </body> </html>
ソースコード(CGIコード)
#!/usr/bin/env python from Cheetah.Template import Template tpl = Template(file='hello.tpl') tpl.message = 'Cheetah' print "Content-Type: text/htmlnn" print tpl
実行方法
1. CGI用フォルダ(cgi-bin等)に配置 2. 実行権限の付与 $ chmod +x hello.py 3. ブラウザで表示 http://localhost/cgi-bin/hello.py
実行結果
Hello, Cheetah World!