33 return hgweb_mod.hgweb(config, name=name, baseui=baseui) |
40 return hgweb_mod.hgweb(config, name=name, baseui=baseui) |
34 |
41 |
35 def hgwebdir(config, baseui=None): |
42 def hgwebdir(config, baseui=None): |
36 return hgwebdir_mod.hgwebdir(config, baseui=baseui) |
43 return hgwebdir_mod.hgwebdir(config, baseui=baseui) |
37 |
44 |
|
45 class httpservice(object): |
|
46 def __init__(self, ui, app, opts): |
|
47 self.ui = ui |
|
48 self.app = app |
|
49 self.opts = opts |
|
50 |
|
51 def init(self): |
|
52 util.setsignalhandler() |
|
53 self.httpd = server.create_server(self.ui, self.app) |
|
54 |
|
55 if self.opts['port'] and not self.ui.verbose: |
|
56 return |
|
57 |
|
58 if self.httpd.prefix: |
|
59 prefix = self.httpd.prefix.strip('/') + '/' |
|
60 else: |
|
61 prefix = '' |
|
62 |
|
63 port = ':%d' % self.httpd.port |
|
64 if port == ':80': |
|
65 port = '' |
|
66 |
|
67 bindaddr = self.httpd.addr |
|
68 if bindaddr == '0.0.0.0': |
|
69 bindaddr = '*' |
|
70 elif ':' in bindaddr: # IPv6 |
|
71 bindaddr = '[%s]' % bindaddr |
|
72 |
|
73 fqaddr = self.httpd.fqaddr |
|
74 if ':' in fqaddr: |
|
75 fqaddr = '[%s]' % fqaddr |
|
76 if self.opts['port']: |
|
77 write = self.ui.status |
|
78 else: |
|
79 write = self.ui.write |
|
80 write(_('listening at http://%s%s/%s (bound to %s:%d)\n') % |
|
81 (fqaddr, port, prefix, bindaddr, self.httpd.port)) |
|
82 self.ui.flush() # avoid buffering of status message |
|
83 |
|
84 def run(self): |
|
85 self.httpd.serve_forever() |