Differences between revisions 1 and 4 (spanning 3 versions)
Revision 1 as of 2009-09-30 05:33:52
Size: 1024
Editor: limodou
Comment:
Revision 4 as of 2009-10-12 03:22:13
Size: 1046
Editor: limodou
Comment:
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
作者:limodou
[[TableOfContents]]
Line 29: Line 31:
from uliweb.core.SimpleFrame import expose from uliweb import expose

作者:limodou TableOfContents

题目要求

写一个Hello,template程序,使用模板来显示Hello,{name},其中name是变量,要由外部传入

框架说明

Uliweb (http://code.google.com/p/uliweb)

步骤

在命令行下操作

1. 创建Project2项目

uliweb makeproject project2

2. 创建Hello App

cd project2
uliweb makeapp Hello

3. 修改apps/Hello/views.py

#coding=utf-8
from uliweb import expose

@expose('/')
def index():
    return {'name':'template'}

4. 在apps/Hello/template下创建index.html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
  <title>Hello World</title>
  <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
</head>
<body>
<h1>Hello, {{=name}}</h1>
</body>
</html>

5. 结束

测试

cd project2
uliweb runserver

访问 http://localhost:8000 即可。

UliwebHelloTemplate (last edited 2009-12-25 07:14:54 by localhost)