From patchwork Mon Jan 28 13:24:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arti Zirk X-Patchwork-Id: 10783699 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 474281390 for ; Mon, 28 Jan 2019 13:30:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 30D932A1E0 for ; Mon, 28 Jan 2019 13:30:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 21F212A25D; Mon, 28 Jan 2019 13:30:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4B2A92A1E0 for ; Mon, 28 Jan 2019 13:30:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726714AbfA1N37 (ORCPT ); Mon, 28 Jan 2019 08:29:59 -0500 Received: from mail-lj1-f172.google.com ([209.85.208.172]:46430 "EHLO mail-lj1-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726683AbfA1N36 (ORCPT ); Mon, 28 Jan 2019 08:29:58 -0500 Received: by mail-lj1-f172.google.com with SMTP id v15-v6so14178445ljh.13 for ; Mon, 28 Jan 2019 05:29:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=UF0p3tqzOEPpvyffgWF2w859fvOZOP0QTUIKZdNj7Ec=; b=I46nOKoq8o83wihz4Qh/tjw1pzvtkjIzCqeONsoEcgRoUJBQfeDS/yl01dG8GA7toO 6f4EcNyIPgNVWqh3mBLTkJ1eYXIeX+v29lEOb8bL3FjO+Q/941mwt+YPq7dTYEvqIZJU 7wJz9sCtIdKziqSS1LAULXfSaCkh7FDzVMM+R3wHP9ejtXktCjtMQCw9rcqdEm9Xj95B v4Z8uQ7aW53x1oKSJuj9jfdIPij4ry20bNXXo2Gwaf7UlFRFc15TJp/Qp5gUE3jgjqHj estC8rfBKu49PMona9c/IwFgMUwnPiXj8cZcQycTt4KtyAoQQYr5Qkchi8xGaG9iLnwW +Yow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=UF0p3tqzOEPpvyffgWF2w859fvOZOP0QTUIKZdNj7Ec=; b=dLUv3vbLIU15Xtt+eMpc3fyAOJUPRL1NKMOMX51XMEgZdOGisjxMy2irLR0fN96WZv 5iIDy21ZBM7oZkYpyuTiJ33LL+oEKKm28LK0kyYI7BY3joPFEUY0kuhzbgWGkbOi83bk an/epQrbkiqXCEkLKeBRTrEWwRU2PIKoxWzP82fCkvi/5M0keOFommgmMi13qATodZyj +fMEihCSco3vE3bdbE6SOldQ7BeeBaKwzeL635YhwvR3WPpc9py8xW+WvekgIcu854cw sgzrJXPqRMAG9L9xwRWB4HEH2hkA5SpkMQbJD0mmWXQvbrWgV4Jx4nb77fZ3xocfT71O ovdA== X-Gm-Message-State: AJcUukfCi1kY5U0sMtoLNlk83HD0x+6h3PPsmFK1oxfFQ3iQ//TxYM9o TyN56kCXeD/sQyoTo55IRHJfNuOaAiz7bA== X-Google-Smtp-Source: ALg8bN5UZSTgvj6dI6q+6y1MXXcqxdIXtRLzGtSbrcYC2N07IYu4YZpRleRawTUfqKbZlEvzL89Omg== X-Received: by 2002:a2e:9b52:: with SMTP id o18-v6mr16851017ljj.108.1548682195104; Mon, 28 Jan 2019 05:29:55 -0800 (PST) Received: from orav.themis.milrem.lan (134-103-235-80.sta.estpak.ee. [80.235.103.134]) by smtp.gmail.com with ESMTPSA id r203sm2839887lff.13.2019.01.28.05.29.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Jan 2019 05:29:54 -0800 (PST) From: Arti Zirk To: git@vger.kernel.org Cc: e@80x24.org, peff@peff.net, jnareb@gmail.com, flavio@polettix.it, gitster@pobox.com, sandals@crustytoothpaste.net, Arti Zirk Subject: [PATCH v2] git-instaweb: Add Python builtin http.server support Date: Mon, 28 Jan 2019 15:24:59 +0200 Message-Id: <20190128132458.31401-1-arti.zirk@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190124161331.25945-1-arti.zirk@gmail.com> References: <20190124161331.25945-1-arti.zirk@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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" <