prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN 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) 
  ```
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `pelican/server.py`
  Content:
  ```
  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 FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
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"}], "after_files": [{"content": "from __future__ import print_function\nimport os\nimport sys\nimport logging\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\nSUFFIXES = ['','.html','/index.html']\n\nclass 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\nHandler = ComplexHTTPRequestHandler\n\ntry:\n    httpd = socketserver.TCPServer((\"\", PORT), Handler)\nexcept OSError as e:\n    logging.error(\"Could not listen on port %s\" % PORT)\n    sys.exit(getattr(e, 'exitcode', 1))\n\n\nlogging.info(\"serving at port %s\" % PORT)\ntry:\n    httpd.serve_forever()\nexcept KeyboardInterrupt as e:\n    logging.info(\"shutting down server\")\n    httpd.socket.close()", "path": "pelican/server.py"}]}