12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- #!/usr/bin/python
- # dul-web - HTTP-based git server
- # Copyright (C) 2010 Google, Inc. <dborowitz@google.com>
- #
- # This program is free software; you can redistribute it and/or
- # modify it under the terms of the GNU General Public License
- # as published by the Free Software Foundation; version 2
- # or (at your option) a later version of the License.
- #
- # This program is distributed in the hope that it will be useful,
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- # GNU General Public License for more details.
- #
- # You should have received a copy of the GNU General Public License
- # along with this program; if not, write to the Free Software
- # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- # MA 02110-1301, USA.
- import os
- import sys
- from dulwich.log_utils import default_logging_config
- from dulwich.repo import Repo
- from dulwich.server import DictBackend
- from dulwich.web import (
- logger,
- HTTPGitApplication,
- HTTPGitRequestHandler,
- )
- from wsgiref.simple_server import (
- make_server,
- )
- # TODO: allow serving on other addresses/ports via command-line flag
- LISTEN_ADDR=''
- PORT = 8000
- if __name__ == "__main__":
- if len(sys.argv) > 1:
- gitdir = sys.argv[1]
- else:
- gitdir = os.getcwd()
- default_logging_config()
- backend = DictBackend({"/": Repo(gitdir)})
- app = HTTPGitApplication(backend)
- server = make_server(LISTEN_ADDR, PORT, app,
- handler_class=HTTPGitRequestHandler)
- logger.info('Listening for HTTP connections on %s:%d', LISTEN_ADDR, PORT)
- server.serve_forever()
|