Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import bottle
- import bottle_mysql
- app = bottle.Bottle()
- # dbhost is optional, default is localhost
- plugin = bottle_mysql.Plugin(dbuser='user', dbpass='pass', dbname='db')
- app.install(plugin)
- @app.route('/show/:<item>')
- def show(item, db):
- db.execute('SELECT * from items where name="%s"', (item,))
- row = db.fetchone()
- if row:
- return template('showitem', page=row)
- return HTTPError(404, "Page not found")
Add Comment
Please, Sign In to add comment