PageRenderTime 24ms CodeModel.GetById 15ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/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
 3from circuits.web import Server, Controller
 4from circuits.web.tools import check_auth, basic_auth
 5
 6
 7class Root(Controller):
 8
 9    def index(self):
10        realm = "Test"
11        users = {"admin": "admin"}
12        encrypt = str
13
14        if check_auth(self.request, self.response, realm, users, encrypt):
15            return "Hello %s" % self.request.login
16
17        return basic_auth(self.request, self.response, realm, users, encrypt)
18
19app = Server(("0.0.0.0", 8000))
20Root().register(app)
21app.run()