# -*- coding: utf-8 -*-
#

"""Simple HTTP Server for Brython Development.
Files are served from subdirectory www, except cgi scripts that are
served from subdirectory cgi-bin
"""


import os
import sys
from webbrowser import open_new_tab
import argparse

# port to be used when the server runs locally
parser = argparse.ArgumentParser()
parser.add_argument('--port', 
    help="The port to be used by the local server")
args = parser.parse_args()

if args.port:
    port = int(args.port)
else:
    port = 8000

# generate static doc pages if not already present
if not os.path.exists(os.path.join(os.getcwd(),'www','static_doc')):
    save_dir = os.getcwd()
    os.chdir(os.path.join(os.getcwd(),'scripts'))
    make_doc = open('make_doc.py', "rb").read()
    make_doc = make_doc.decode("utf-8")
    exec(make_doc)
    os.chdir(save_dir)

os.chdir(os.path.join(os.getcwd(), 'www'))

try:
    import http.server as server
    from http.server import CGIHTTPRequestHandler
except:
    import BaseHTTPServer as server
    from CGIHTTPServer import CGIHTTPRequestHandler

cgi_dir = os.path.join(os.path.dirname(os.getcwd()), 'cgi-bin')

class RequestHandler(CGIHTTPRequestHandler):

    def translate_path(self, path):
        """For paths starting with /cgi-bin/, serve from cgi_dir"""
        elts = path.split('/')
        if len(elts)>1 and elts[0]=='' and elts[1]=='cgi-bin':
            return os.path.join(cgi_dir,*elts[2:])
        return CGIHTTPRequestHandler.translate_path(self, path)

server_address, handler = ('', port), RequestHandler
httpd = server.HTTPServer(server_address, handler)
print(__doc__)
print(("Server running on port http://localhost:{}.".format(server_address[1])))
print("Press CTRL+C to Quit.")
open_new_tab("http://localhost:{}/".format(server_address[1]))
httpd.serve_forever()


@@ -360,21 +360,16 @@
 -port', 
-%0A    
 help=%22Th
@@ -408,16 +408,278 @@
 erver%22)%0A
+%0A# generate docs?%0A# when testing new code on your repo it is not necessary to generate docs all%0A# the time so this option allows you to avoid this process%0Aparser.add_argument(%0A    '--no-docs', %0A    help=%22Do not generate static docs.%22, %0A    action=%22store_true%22)%0A%0A
 args = p
@@ -761,16 +761,41 @@
 = 8000%0A%0A
+if not args.no_docs:%0A    
 # genera
@@ -837,16 +837,20 @@
 present%0A
+    
 if not o
@@ -910,16 +910,20 @@
 doc')):%0A
+    
     save
@@ -937,24 +937,28 @@
 os.getcwd()%0A
+    
     os.chdir
@@ -995,24 +995,28 @@
 ipts'))%0A    
+ 
+   
 make_doc = o
@@ -1047,24 +1047,28 @@
 .read()%0A    
+  
+  
 make_doc = m
@@ -1091,16 +1091,20 @@
 utf-8%22)%0A
+    
     exec
@@ -1114,16 +1114,20 @@
 ke_doc)%0A
+    
     os.c

Add a --no-docs option to server.py to improve the developer experience.