1.安装web.py,去cmd窗口输入pip install web.py
在代码里输入
#!/usr/bin/env python
import importlib
import sys
importlib.reload(sys)
import web
urls=(
‘/index’,’index’,
‘/(.*)’,’index’,
)
app=web.application(urls,globals())
class index:
def GET(self,name):
return “hello world!”
if name==”main“:
app.run()
添加模板的时候在py同文件夹新建templates文件夹
并在内放入相应html
运行下列代码
#!/usr/bin/env python
import importlib
import sys
importlib.reload(sys)
import web
urls=(
‘/index’,’index’,
‘/(.*)’,’index’,
)
render = web.template.render(‘templates/’)
app=web.application(urls,globals())
class index:
def GET(self,name):
return render.Fuck()
if name==”main“:
app.run()