import web
urls = ('/', 'index')
class index:def GET(self):return "Hello, world!"
if __name__ == "__main__":app = web.application(urls, globals())app.run()
movies = [{'title': 'Forrest Gump','year': 1994,},{'title': 'Titanic','year': 1997,},
def GET(self):page = ''for m in movies:page += '%s (%d)\n' % (m['title'], m['year'])return page
Forrest Gump (1994)Titanic (1997)
render = web.template.render('templates/')
def GET(self):return render.index()
render = web.template.render('muban/')render.shouye()
<h1>Crossin's Movie Site</h1>
Crossin's Movie Site
def GET(self):return render.index(movies)
$def with (movies)<h1>Crossin's Movie Site</h1>$movies
$for movie in movies:<li>$movie['title'], $movie['year']</li>
382 Bytes, 下载次数: 559
code.py
雏菊 发表于 2016-3-6 12:16
问什么我都输入好了以后,打开地址出现这个: at
'utf8' codec can't decode byte 0xce in position 7: i ...
雏菊 发表于 2016-3-6 12:16
问什么我都输入好了以后,打开地址出现这个: at
'utf8' codec can't decode byte 0xce in position 7: i ...
nekonekobox 发表于 2017-2-22 00:25
if __name__ == "__main__":
app = web.application(urls, globals())
app.run()
布拉格广场 发表于 2017-6-16 20:13
Traceback (most recent call last):
File "D:\python\lib\site-packages\web.py-0.40.dev0-py3.6.egg\we ...
fionalailai 发表于 2020-3-17 23:15
为什么我一致code.py,结果中显示http://0.0.0.0:8080/之后整个IDLE就卡住了,每次都得强制关闭,重新打开 ...
欢迎光临 Crossin的编程教室 (https://bbs.crossincode.com/) | Powered by Discuz! X2.5 |