From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oi0-f46.google.com (mail-oi0-f46.google.com [209.85.218.46]) by dpdk.org (Postfix) with ESMTP id 55AD4C490 for ; Thu, 28 Jan 2016 15:34:19 +0100 (CET) Received: by mail-oi0-f46.google.com with SMTP id o124so27393686oia.3 for ; Thu, 28 Jan 2016 06:34:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=JKSs5neg1CkpCElPYFTNhTxS8KKkeapuraqDt21Lkwk=; b=mZvmlltd4JLzr+RAc3YrqImRV5XJV3thFA65PeBsMnuSeStxCCiRoWaGaA9qJKNWdP M1qT85fkksyqjpbAv1nbX6BRJvgX0dvNRGJMJS7jA5s1j8aY271Fs4djAawcw3aSHMCF vtB8577emQswoRIwIbQjPqjNLPBJPxUfRDgekKH4SixJ7BHkqmE50qjBag+iIg3Zky03 suP6avhDBB5+Y2BNK1MByq1Wzn4BxVJN+5vbCy6cZZ/C4gggns/ZkIpmaWiVXdlby8LI ImNIYGdbQJakQrxXXsgd9os0DyCZzdzxUjbVrjjpJXL3oq0Rx3YLguKFjtCiVwNJpw/d dCPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=JKSs5neg1CkpCElPYFTNhTxS8KKkeapuraqDt21Lkwk=; b=F2xVVDGWs0LIBfz4XCwo/5sgWIrqpIA4WZSM2WTu/KeVvmiP9fwHSa95zB6tYAik59 h+fKQ2b3D2b9afpbBG6vLjJxmKnX5N6txFa1quCe42B5Iw/52vu/vONZi5GslPHnsFOA 5bb1I7ztevW4mO+GQl1PI524+QOznmpyjVzFxUFtmSAkSIzHUgwS4u8jT7K5U+8t54tA So90VhaqY6fLcQdU/LAdP0B7w+BiCy2PELuZyaxYP+AXlmM2gdE6Ug/V2ou0LGUNqGdb RA0hJv4yCRba3ZR1E1T2JZbado+lmlFv2Ml0cDvDta61fnCXPXbDrOeRpHKX725L/ANi ufMg== X-Gm-Message-State: AG10YOTmU2b/qAXIAYFweDqfns19j4uGvZkDrBr+/lAsZcoh9I03Lrou7zrOAxP+3vUg/lbrkxVHqwvAwXLhxCWS MIME-Version: 1.0 X-Received: by 10.202.213.78 with SMTP id m75mr2440604oig.56.1453991658849; Thu, 28 Jan 2016 06:34:18 -0800 (PST) Received: by 10.60.76.201 with HTTP; Thu, 28 Jan 2016 06:34:18 -0800 (PST) Received: by 10.60.76.201 with HTTP; Thu, 28 Jan 2016 06:34:18 -0800 (PST) In-Reply-To: <1453987422-22469-1-git-send-email-harry.van.haaren@intel.com> References: <1453987422-22469-1-git-send-email-harry.van.haaren@intel.com> Date: Thu, 28 Jan 2016 15:34:18 +0100 Message-ID: From: Vincent JARDIN To: Harry Van Haaren Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Cc: web@dpdk.org Subject: Re: [dpdk-web] [PATCH] serve_local.py: add script to serve locally X-BeenThere: web@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: website maintenance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 Jan 2016 14:34:19 -0000 Could you write a Dockerfile to test it when updating website? Dockerfile would run serve_local.py. Le 28 janv. 2016 14:24, "Harry van Haaren" a =C3=A9crit : > This patch adds a basic Python web server that will serve > the DPDK site for testing purposes. Basic URL re-writing > and folder scanning is implementent to make the links work. > > Signed-off-by: Harry van Haaren > --- > > Makefile | 3 +++ > scripts/serve_local.py | 58 > ++++++++++++++++++++++++++++++++++++++++++++++++++ > 2 files changed, 61 insertions(+) > create mode 100644 Makefile > create mode 100644 scripts/serve_local.py > > diff --git a/Makefile b/Makefile > new file mode 100644 > index 0000000..2a7602a > --- /dev/null > +++ b/Makefile > @@ -0,0 +1,3 @@ > + > +local: > + python scripts/serve_local.py > diff --git a/scripts/serve_local.py b/scripts/serve_local.py > new file mode 100644 > index 0000000..ef59474 > --- /dev/null > +++ b/scripts/serve_local.py > @@ -0,0 +1,58 @@ > +import BaseHTTPServer > +from os import curdir, sep, listdir > + > +folders =3D ["./","./doc","./dev/"] > + > +html_files =3D [] > + > +for fol in folders: > + all_files =3D listdir(fol) > + for f in all_files: > + if f.endswith(".html") and not f.startswith("cgit"): > + html_files.append(f[:len(f)-5]) > + > +for f in html_files: > + #print("final files %s" % f) > + pass > + > +class DPDK_Handler(BaseHTTPServer.BaseHTTPRequestHandler): > + def do_GET(self): > + mimetype =3D "" > + if self.path.endswith(".html") or self.path.endswith("/"): > + mimetype=3D'text/html' > + > + # Rudimental path rewriting to make links work > + path =3D self.path > + if path =3D=3D "/": > + path =3D "index.html" > + else: > + for f in html_files: > + if path.endswith(f) and not path.endswith(".html"): > + path +=3D ".html" > + break > + > + try: > + f =3D open(curdir + sep + path) > + self.send_response(200) > + self.send_header('Content-type',mimetype) > + self.end_headers() > + self.wfile.write(f.read()) > + f.close() > + except IOError: > + self.send_error(404,'File Not Found: %s' % path) > + > +def run(server_class=3DBaseHTTPServer.HTTPServer, > + handler_class=3DBaseHTTPServer.BaseHTTPRequestHandler): > + server_address =3D ('', 8000) > + httpd =3D server_class(server_address, handler_class) > + httpd.serve_forever() > + > +try: > + run(handler_class=3DDPDK_Handler) > +except BaseHTTPServer.socket.error: > + print("#######################################") > + print("# ERROR: Socket already in use. #") > + print("# Are you running the server already? #") > + print("#######################################") > +except KeyboardInterrupt: > + print("\tQuitting, bye bye!") > -- > 2.5.0 > >