|
python越来越火,都上升到编程语言第8了,闲来无事看看能有啥用,就选择了web.py研究下,顺便做个笔记,免得以后忘记了
一个简单例子:
import web,os
from web.contrib.template import render_jinja
import hessianUtil
import json
urls = (
'/home', 'home'
)
app_root=os.path.dirname(__file__)
templates_path=os.path.join(app_root,'templates').replace("\\","/")
render = render_jinja(
templates_path, # 设置模板路径.
encoding = 'utf-8', # 编码.
)
class home:
def GET(self):
return render.home({})
app=web.application(urls,globals())
if __name__ == "__main__":
app.run() |
|
|