/examples/web/httpauth.py

https://bitbucket.org/prologic/circuits/ · Python · 21 lines · 13 code · 7 blank · 1 comment · 1 complexity · c9d12fa5728cc7257c0108a0e4bc8a84 MD5 · raw file

  1. #!/usr/bin/env python
  2. from circuits.web import Server, Controller
  3. from circuits.web.tools import check_auth, basic_auth
  4. class Root(Controller):
  5. def index(self):
  6. realm = "Test"
  7. users = {"admin": "admin"}
  8. encrypt = str
  9. if check_auth(self.request, self.response, realm, users, encrypt):
  10. return "Hello %s" % self.request.login
  11. return basic_auth(self.request, self.response, realm, users, encrypt)
  12. app = Server(("0.0.0.0", 8000))
  13. Root().register(app)
  14. app.run()