/examples/web/httpauth.py
https://bitbucket.org/prologic/circuits/ · Python · 21 lines · 13 code · 7 blank · 1 comment · 1 complexity · c9d12fa5728cc7257c0108a0e4bc8a84 MD5 · raw file
- #!/usr/bin/env python
- from circuits.web import Server, Controller
- from circuits.web.tools import check_auth, basic_auth
- class Root(Controller):
- def index(self):
- realm = "Test"
- users = {"admin": "admin"}
- encrypt = str
- if check_auth(self.request, self.response, realm, users, encrypt):
- return "Hello %s" % self.request.login
- return basic_auth(self.request, self.response, realm, users, encrypt)
- app = Server(("0.0.0.0", 8000))
- Root().register(app)
- app.run()