import web db web database dbn sqlite db test db render web template r

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import web
db = web.database(dbn='sqlite',db='test.db')
render = web.template.render('templates/')
urls = (
'/', 'index',
'/add', 'add'
)
app = web.application(urls, globals())
class index:
def GET(self):
links = db.select('links')
return render.index(links)
class add:
def POST(self):
i = web.input()
n = db.insert('links', url=i.url, descr=i.descr)
raise web.seeother('/')
if __name__ == "__main__":
app.run()