$ pip install web.py python import web urls = ( '/hello', 'hello' ) class hello: def GET(self): return "Hello, world!" if __name__ == "__main__": app = web.application(urls, globals()) app.run() python import web render = web.template.render('templates/') urls = ( '/hello/(.*)', 'hello' ) class hello: def GET(self, name): return render.hello(name=name) if __name__ == "__main__": app = web.application(urls, globals()) app.run() python import web db = web.database(dbn='sqlite', db='test.db') urls = ( '/users', 'users' ) class users: def GET(self): result = db.query('SELECT * FROM users') return str(result.list()) if __name__ == "__main__": app = web.application(urls, globals()) app.run()


上一篇:
下一篇:
切换中文