From: Arti Zirk Date: Mon, 28 Jan 2019 13:24:59 GMT Subject: [PATCH v2] git-instaweb: Add Python builtin http.server support Message-ID: <20190128132458.31401-1-arti.zirk@gmail.com> In-Reply-To: <20190124161331.25945-1-arti.zirk@gmail.com> With this patch it is possible to launch git-instaweb by using Python http.server CGI handler via `-d python` option. git-instaweb generates a small wrapper around the http.server (in GIT_DIR/gitweb/) that address a limitation of the CGI handler where CGI scripts have to be in a cgi-bin subdirectory and directory index can't be easily changed. To keep the implementation small, gitweb is running on url `/cgi-bin/gitweb.cgi` and an automatic redirection is done when opening `/`. The generated wrapper is compatible with both Python 2 and 3. Python is by default installed on most modern Linux distributions which enables running `git instaweb -d python` without needing anything else. Signed-off-by: Arti Zirk --- Changes v1..v2: - Add compatibily for Python 2, tested with 2.7, 3.4, 3.5, 3.6, 3.7 Notes: Base Ref: master Web-Diff: https://github.com/artizirk/git/commit/fe30635765 Checkout: git fetch https://github.com/artizirk/git instaweb-python-v2 && git checkout fe30635765 ### Interdiff (v1..v2): diff --git a/git-instaweb.sh b/git-instaweb.sh index c8f9f03447..7c55229773 100755 --- a/git-instaweb.sh +++ b/git-instaweb.sh @@ -614,10 +614,11 @@ python_conf() { ln -sf "$root/gitweb.cgi" "$fqgitdir/gitweb/$httpd_only/cgi-bin/gitweb.cgi" ln -sf "$root/static" "$fqgitdir/gitweb/$httpd_only/" - # generate a standalone 'python3 http.server' script in $fqgitdir/gitweb - # This asumes that python3 is in user's $PATH + # generate a standalone 'python http.server' script in $fqgitdir/gitweb + # This asumes that python is in user's $PATH + # This script is Python 2 and 3 compatible cat > "$fqgitdir/gitweb/gitweb.py" < "$fqgitdir/gitweb/gitweb.py" < "$fqgitdir/gitweb/gitweb_config.perl" <