pip install web.py
python
import web
urls = (
'/', 'index'
)
app = web.application(urls, globals())
class index:
def GET(self):
return "Hello, Web.py!"
if __name__ == "__main__":
app.run()
python app.py
python
import web
urls = (
'/hello', 'hello'
)
app = web.application(urls, globals())
class hello:
@app.route('/')
def GET(self):
return "Hello, Web.py!"
@app.route('/name')
def GET(self):
return "My name is Web.py!"
if __name__ == "__main__":
app.run()
python
import web
render = web.template.render('templates/')
urls = (
'/', 'index'
)
app = web.application(urls, globals())
db = web.database(dbn='mysql', db='mydb', user='myuser', pw='mypassword')
class index:
def GET(self):
data = db.select('mytable')
return render.index(data)
if __name__ == "__main__":
app.run()