Neonian

Untitled

May 10th, 2016
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. import bottle
  2. import bottle_mysql
  3.  
  4. app = bottle.Bottle()
  5. # dbhost is optional, default is localhost
  6. plugin = bottle_mysql.Plugin(dbuser='user', dbpass='pass', dbname='db')
  7. app.install(plugin)
  8.  
  9. @app.route('/show/:<item>')
  10. def show(item, db):
  11. db.execute('SELECT * from items where name="%s"', (item,))
  12. row = db.fetchone()
  13. if row:
  14. return template('showitem', page=row)
  15. return HTTPError(404, "Page not found")
Add Comment
Please, Sign In to add comment