PageRenderTime 10ms CodeModel.GetById 1ms app.highlight 5ms RepoModel.GetById 2ms app.codeStats 0ms

/examples/web/virtualhosts.py

https://bitbucket.org/prologic/circuits/
Python | 38 lines | 23 code | 14 blank | 1 comment | 0 complexity | c53fcdafc2b67d617aac56f853f53427 MD5 | raw file
 1#!/usr/bin/env python
 2
 3from circuits.web import Server, Controller
 4from circuits.web.dispatchers import VirtualHosts
 5
 6
 7class Root(Controller):
 8
 9    def index(self):
10        return "I am the main vhost"
11
12
13class Foo(Controller):
14
15    channel = "/foo"
16
17    def index(self):
18        return "I am foo."
19
20
21class Bar(Controller):
22
23    channel = "/bar"
24
25    def index(self):
26        return "I am bar."
27
28domains = {
29    "foo.localdomain:8000": "foo",
30    "bar.localdomain:8000": "bar",
31}
32
33app = Server(("0.0.0.0", 8000))
34VirtualHosts(domains).register(app)
35Root().register(app)
36Foo().register(app)
37Bar().register(app)
38app.run()