You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 line
941B

  1. import web
  2. from web import form
  3. import mysql.connector
  4. urls = (
  5. '/', 'index'
  6. )
  7. db2 = mysql.connector.connect(user='root', password='root',
  8. host='10.5.0.5',
  9. database='db')
  10. # Initialize application using the web py framework
  11. app = web.application(urls, globals())
  12. # Get html templates
  13. render = web.template.render('templates/')
  14. login_form = form.Form(
  15. form.Textbox("username", description="Username"),
  16. form.Password("password", description="Password"),
  17. form.Button("submit", type="submit", description="Login"),
  18. )
  19. class index():
  20. def GET(self):
  21. cursor = db2.cursor()
  22. query = ("SELECT userid, username from users")
  23. cursor.execute(query)
  24. friends = cursor.fetchall()
  25. return render.index(login_form, friends)
  26. if __name__ == "__main__":
  27. app.run()
  28. application = app.wsgifunc()