(self, environ, start_response)
| 11 | self.mapping = mapping |
| 12 | |
| 13 | def __call__(self, environ, start_response): |
| 14 | host = environ.get("HTTP_HOST", "") |
| 15 | host = host.split(":")[0] # strip port |
| 16 | |
| 17 | for pattern, app in self.mapping: |
| 18 | if re.match("^" + pattern + "$", host): |
| 19 | return app(environ, start_response) |
| 20 | else: |
| 21 | start_response("404 Not Found", []) |
| 22 | return [b""] |
| 23 | |
| 24 | def hello(environ, start_response): |
| 25 | start_response("200 OK", [("Content-Type", "text/plain")]) |