prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Allow nice URLs on devserver
  When you publish the website is quite easy to implement nice URLs. For example an nginx configuraiton like this would provide you with nice URLs for your website:
  
  ```
  index index.php index.html index.htm index.shtml;
  root /var/www/example.com/public_html;
  try_files $uri $uri.html $uri/index.html index.html;
  ```
  
  Now the problem is tha the devserver does not have the save behaviour, and so far I am now aware of any way to configure it to do this.
  
  ```
  /output/index.html              http://localhost:8000
  /output/contact.html              http://localhost:8000/contact
  /output/sales/index.html              http://localhost:8000/sales
  /output/sales/index.html              http://localhost:8000/sales/    (yes the same) 
  ```
  
  
  </issue>
  <code>
  [start of pelican/server.py]
  1 from __future__ import print_function
  2 import sys
  3 try:
  4     import SimpleHTTPServer as srvmod
  5 except ImportError:
  6     import http.server as srvmod  # NOQA
  7 
  8 try:
  9     import SocketServer as socketserver
  10 except ImportError:
  11     import socketserver  # NOQA
  12 
  13 PORT = len(sys.argv) == 2 and int(sys.argv[1]) or 8000
  14 
  15 Handler = srvmod.SimpleHTTPRequestHandler
  16 
  17 try:
  18     httpd = socketserver.TCPServer(("", PORT), Handler)
  19 except OSError as e:
  20     print("Could not listen on port", PORT)
  21     sys.exit(getattr(e, 'exitcode', 1))
  22 
  23 
  24 print("serving at port", PORT)
  25 try:
  26     httpd.serve_forever()
  27 except KeyboardInterrupt as e:
  28     print("shutting down server")
  29     httpd.socket.close()
  30
  [end of pelican/server.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/pelican/server.py b/pelican/server.py
  --- a/pelican/server.py
  +++ b/pelican/server.py
  @@ -1,5 +1,7 @@
   from __future__ import print_function
  +import os
   import sys
  +import logging
   try:
       import SimpleHTTPServer as srvmod
   except ImportError:
  @@ -11,19 +13,36 @@
       import socketserver  # NOQA
   
   PORT = len(sys.argv) == 2 and int(sys.argv[1]) or 8000
  +SUFFIXES = ['','.html','/index.html']
   
  -Handler = srvmod.SimpleHTTPRequestHandler
  +class ComplexHTTPRequestHandler(srvmod.SimpleHTTPRequestHandler):
  +    def do_GET(self):
  +        # we are trying to detect the file by having a fallback mechanism
  +        r = None
  +        for suffix in SUFFIXES:
  +            if not hasattr(self,'original_path'):
  +                self.original_path = self.path
  +            self.path = self.original_path + suffix
  +            path = self.translate_path(self.path)
  +            if os.path.exists(path):
  +                r = srvmod.SimpleHTTPRequestHandler.do_GET(self)
  +            if r is not None:
  +                break
  +            logging.warning("Unable to find %s file." % self.path)
  +        return r
  +
  +Handler = ComplexHTTPRequestHandler
   
   try:
       httpd = socketserver.TCPServer(("", PORT), Handler)
   except OSError as e:
  -    print("Could not listen on port", PORT)
  +    logging.error("Could not listen on port %s" % PORT)
       sys.exit(getattr(e, 'exitcode', 1))
   
   
  -print("serving at port", PORT)
  +logging.info("serving at port %s" % PORT)
   try:
       httpd.serve_forever()
   except KeyboardInterrupt as e:
  -    print("shutting down server")
  -    httpd.socket.close()
  +    logging.info("shutting down server")
  +    httpd.socket.close()
  \ No newline at end of file
  
verification_info: {"golden_diff": "diff --git a/pelican/server.py b/pelican/server.py\n--- a/pelican/server.py\n+++ b/pelican/server.py\n@@ -1,5 +1,7 @@\n from __future__ import print_function\n+import os\n import sys\n+import logging\n try:\n     import SimpleHTTPServer as srvmod\n except ImportError:\n@@ -11,19 +13,36 @@\n     import socketserver  # NOQA\n \n PORT = len(sys.argv) == 2 and int(sys.argv[1]) or 8000\n+SUFFIXES = ['','.html','/index.html']\n \n-Handler = srvmod.SimpleHTTPRequestHandler\n+class ComplexHTTPRequestHandler(srvmod.SimpleHTTPRequestHandler):\n+    def do_GET(self):\n+        # we are trying to detect the file by having a fallback mechanism\n+        r = None\n+        for suffix in SUFFIXES:\n+            if not hasattr(self,'original_path'):\n+                self.original_path = self.path\n+            self.path = self.original_path + suffix\n+            path = self.translate_path(self.path)\n+            if os.path.exists(path):\n+                r = srvmod.SimpleHTTPRequestHandler.do_GET(self)\n+            if r is not None:\n+                break\n+            logging.warning(\"Unable to find %s file.\" % self.path)\n+        return r\n+\n+Handler = ComplexHTTPRequestHandler\n \n try:\n     httpd = socketserver.TCPServer((\"\", PORT), Handler)\n except OSError as e:\n-    print(\"Could not listen on port\", PORT)\n+    logging.error(\"Could not listen on port %s\" % PORT)\n     sys.exit(getattr(e, 'exitcode', 1))\n \n \n-print(\"serving at port\", PORT)\n+logging.info(\"serving at port %s\" % PORT)\n try:\n     httpd.serve_forever()\n except KeyboardInterrupt as e:\n-    print(\"shutting down server\")\n-    httpd.socket.close()\n+    logging.info(\"shutting down server\")\n+    httpd.socket.close()\n\\ No newline at end of file\n", "issue": "Allow nice URLs on devserver\nWhen you publish the website is quite easy to implement nice URLs. For example an nginx configuraiton like this would provide you with nice URLs for your website:\n\n```\nindex index.php index.html index.htm index.shtml;\nroot /var/www/example.com/public_html;\ntry_files $uri $uri.html $uri/index.html index.html;\n```\n\nNow the problem is tha the devserver does not have the save behaviour, and so far I am now aware of any way to configure it to do this.\n\n```\n/output/index.html              http://localhost:8000\n/output/contact.html              http://localhost:8000/contact\n/output/sales/index.html              http://localhost:8000/sales\n/output/sales/index.html              http://localhost:8000/sales/    (yes the same) \n```\n\n", "before_files": [{"content": "from __future__ import print_function\nimport sys\ntry:\n    import SimpleHTTPServer as srvmod\nexcept ImportError:\n    import http.server as srvmod  # NOQA\n\ntry:\n    import SocketServer as socketserver\nexcept ImportError:\n    import socketserver  # NOQA\n\nPORT = len(sys.argv) == 2 and int(sys.argv[1]) or 8000\n\nHandler = srvmod.SimpleHTTPRequestHandler\n\ntry:\n    httpd = socketserver.TCPServer((\"\", PORT), Handler)\nexcept OSError as e:\n    print(\"Could not listen on port\", PORT)\n    sys.exit(getattr(e, 'exitcode', 1))\n\n\nprint(\"serving at port\", PORT)\ntry:\n    httpd.serve_forever()\nexcept KeyboardInterrupt as e:\n    print(\"shutting down server\")\n    httpd.socket.close()\n", "path": "pelican/server.py"}]}