# -*- coding: utf-8 -*-
import web
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
urls = (
'/','Index',
'/name','Name',
'/page/list_(d+).html','Page',
'/movie/(d+).html','Movie',
)
render = web.template.render('templates')
db=web.database(dbn="mysql",host="localhost",port =3306,user="root",passwd="123456",db="test",charset="utf8")
class Index(object):
def GET(self):
data=db.query("select *from dianying where id limit 0,15 ")#取出十五个数据
return render.dianying(data)
class Page(object):
def GET(self,pn):
pn=int(pn)
data=db.query("select *from dianying where id limit %s,15 "%(pn*15))
if pn==1:
return render.dianying(data,"",pn+1)#上下翻页
return render.dianying(data,pn-1,pn+1)
class Movie(object):
def GET(self,id):
data=db.query("select *from dianying where id=%s"%id)
return render.content(data[0])
if __name__ == '__main__':
web.application(urls,globals()).run()