Skip to content

Commit 2762a87

Browse files
committed
ex50 第一个网站
1 parent d554a5f commit 2762a87

File tree

6 files changed

+46
-0
lines changed

6 files changed

+46
-0
lines changed

gothonweb/bin/app.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#coding:utf-8
2+
import web
3+
4+
urls = (
5+
'/', 'Index'
6+
)
7+
8+
app = web.application(urls, globals())
9+
10+
render = web.template.render('templates/') # 渲染templates/文件夹下的index
11+
12+
class Index(object):
13+
def GET(self):
14+
greeting = "Hello World1"
15+
#return render.index(greeting = greeting # 把greeting变量传递给index网页模板中的greeting
16+
return render.foo(greeting = greeting) #templates文件夹下创建了一个新的foo.html的模板
17+
if __name__ == "__main__":
18+
app.run()

gothonweb/bin/app.pyc

751 Bytes
Binary file not shown.

gothonweb/gothonweb/__init__.py

Whitespace-only changes.

gothonweb/templates/foo.html

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
$def with (greeting)
2+
<html>
3+
<head>
4+
<title>Gothons Of Planet Percal #25</title>
5+
</head>
6+
<body>
7+
8+
$if greeting:
9+
I just wanted to say <em style="color: green; font-size: 2em;">$greeting</em>.
10+
$else:
11+
<em>Hello</em>, world!
12+
13+
</body>
14+
</html>

gothonweb/templates/index.html

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
$def with (greeting)
2+
<html>
3+
<head>
4+
<title>Gothons Of Planet Percal #25</title>
5+
</head>
6+
<body>
7+
8+
$if greeting:
9+
I just wanted to say <em style="color: green; font-size: 2em;">$greeting</em>.
10+
$else:
11+
<em>Hello</em>, world!
12+
13+
</body>
14+
</html>

gothonweb/tests/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)