We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Asyncio NotImplemented Error after Python 3.8.0
Using a new install of Python 3.8.0, pip installed latest version of MkDocs, and then tried to run `mkdocs serve`, which encountered the below error. 

I tried again on a new docs directory (`mkdocs new testing`), but encountered the same issue again. 

Python version: 3.8.0
OS: Windows 10 Pro v1709

error:
```
C:\dev\testing
λ  mkdocs serve
INFO    -  Building documentation...
INFO    -  Cleaning site directory
[I 191017 14:49:48 server:296] Serving on http://127.0.0.1:8000
Traceback (most recent call last):
  File "c:\users\aleksandr.skobelev\appdata\local\programs\python\python38\lib\runpy.py", line 192, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "c:\users\aleksandr.skobelev\appdata\local\programs\python\python38\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\aleksandr.skobelev\AppData\Local\Programs\Python\Python38\Scripts\mkdocs.exe\__main__.py", line 9, in <module>
  File "c:\users\aleksandr.skobelev\appdata\local\programs\python\python38\lib\site-packages\click\core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "c:\users\aleksandr.skobelev\appdata\local\programs\python\python38\lib\site-packages\click\core.py", line 717, in main
    rv = self.invoke(ctx)
  File "c:\users\aleksandr.skobelev\appdata\local\programs\python\python38\lib\site-packages\click\core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "c:\users\aleksandr.skobelev\appdata\local\programs\python\python38\lib\site-packages\click\core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "c:\users\aleksandr.skobelev\appdata\local\programs\python\python38\lib\site-packages\click\core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "c:\users\aleksandr.skobelev\appdata\local\programs\python\python38\lib\site-packages\mkdocs\__main__.py", line 128, in serve_command
    serve.serve(
  File "c:\users\aleksandr.skobelev\appdata\local\programs\python\python38\lib\site-packages\mkdocs\commands\serve.py", line 124, in serve
    _livereload(host, port, config, builder, site_dir)
  File "c:\users\aleksandr.skobelev\appdata\local\programs\python\python38\lib\site-packages\mkdocs\commands\serve.py", line 58, in _livereload
    server.serve(root=site_dir, host=host, port=port, restart_delay=0)
  File "c:\users\aleksandr.skobelev\appdata\local\programs\python\python38\lib\site-packages\livereload\server.py", line 298, in serve
    self.application(
  File "c:\users\aleksandr.skobelev\appdata\local\programs\python\python38\lib\site-packages\livereload\server.py", line 253, in application
    app.listen(port, address=host)
  File "c:\users\aleksandr.skobelev\appdata\local\programs\python\python38\lib\site-packages\tornado\web.py", line 2112, in listen
    server.listen(port, address)
  File "c:\users\aleksandr.skobelev\appdata\local\programs\python\python38\lib\site-packages\tornado\tcpserver.py", line 152, in listen
    self.add_sockets(sockets)
  File "c:\users\aleksandr.skobelev\appdata\local\programs\python\python38\lib\site-packages\tornado\tcpserver.py", line 165, in add_sockets
    self._handlers[sock.fileno()] = add_accept_handler(
  File "c:\users\aleksandr.skobelev\appdata\local\programs\python\python38\lib\site-packages\tornado\netutil.py", line 279, in add_accept_handler
    io_loop.add_handler(sock, accept_handler, IOLoop.READ)
  File "c:\users\aleksandr.skobelev\appdata\local\programs\python\python38\lib\site-packages\tornado\platform\asyncio.py", line 99, in add_handler
    self.asyncio_loop.add_reader(fd, self._handle_events, fd, IOLoop.READ)
  File "c:\users\aleksandr.skobelev\appdata\local\programs\python\python38\lib\asyncio\events.py", line 501, in add_reader
    raise NotImplementedError
NotImplementedError
```

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `mkdocs/commands/serve.py`
Content:
```
1 from __future__ import unicode_literals
2 
3 import logging
4 import shutil
5 import tempfile
6 
7 from os.path import isfile, join
8 from mkdocs.commands.build import build
9 from mkdocs.config import load_config
10 
11 log = logging.getLogger(__name__)
12 
13 
14 def _get_handler(site_dir, StaticFileHandler):
15 
16     from tornado.template import Loader
17 
18     class WebHandler(StaticFileHandler):
19 
20         def write_error(self, status_code, **kwargs):
21 
22             if status_code in (404, 500):
23                 error_page = '{}.html'.format(status_code)
24                 if isfile(join(site_dir, error_page)):
25                     self.write(Loader(site_dir).load(error_page).generate())
26                 else:
27                     super(WebHandler, self).write_error(status_code, **kwargs)
28 
29     return WebHandler
30 
31 
32 def _livereload(host, port, config, builder, site_dir):
33 
34     # We are importing here for anyone that has issues with livereload. Even if
35     # this fails, the --no-livereload alternative should still work.
36     from livereload import Server
37     import livereload.handlers
38 
39     class LiveReloadServer(Server):
40 
41         def get_web_handlers(self, script):
42             handlers = super(LiveReloadServer, self).get_web_handlers(script)
43             # replace livereload handler
44             return [(handlers[0][0], _get_handler(site_dir, livereload.handlers.StaticFileHandler), handlers[0][2],)]
45 
46     server = LiveReloadServer()
47 
48     # Watch the documentation files, the config file and the theme files.
49     server.watch(config['docs_dir'], builder)
50     server.watch(config['config_file_path'], builder)
51 
52     for d in config['theme'].dirs:
53         server.watch(d, builder)
54 
55     # Run `serve` plugin events.
56     server = config['plugins'].run_event('serve', server, config=config)
57 
58     server.serve(root=site_dir, host=host, port=port, restart_delay=0)
59 
60 
61 def _static_server(host, port, site_dir):
62 
63     # Importing here to seperate the code paths from the --livereload
64     # alternative.
65     from tornado import ioloop
66     from tornado import web
67 
68     application = web.Application([
69         (r"/(.*)", _get_handler(site_dir, web.StaticFileHandler), {
70             "path": site_dir,
71             "default_filename": "index.html"
72         }),
73     ])
74     application.listen(port=port, address=host)
75 
76     log.info('Running at: http://%s:%s/', host, port)
77     log.info('Hold ctrl+c to quit.')
78     try:
79         ioloop.IOLoop.instance().start()
80     except KeyboardInterrupt:
81         log.info('Stopping server...')
82 
83 
84 def serve(config_file=None, dev_addr=None, strict=None, theme=None,
85           theme_dir=None, livereload='livereload'):
86     """
87     Start the MkDocs development server
88 
89     By default it will serve the documentation on http://localhost:8000/ and
90     it will rebuild the documentation and refresh the page automatically
91     whenever a file is edited.
92     """
93 
94     # Create a temporary build directory, and set some options to serve it
95     # PY2 returns a byte string by default. The Unicode prefix ensures a Unicode
96     # string is returned. And it makes MkDocs temp dirs easier to identify.
97     site_dir = tempfile.mkdtemp(prefix='mkdocs_')
98 
99     def builder():
100         log.info("Building documentation...")
101         config = load_config(
102             config_file=config_file,
103             dev_addr=dev_addr,
104             strict=strict,
105             theme=theme,
106             theme_dir=theme_dir,
107             site_dir=site_dir
108         )
109         # Override a few config settings after validation
110         config['site_url'] = 'http://{0}/'.format(config['dev_addr'])
111 
112         live_server = livereload in ['dirty', 'livereload']
113         dirty = livereload == 'dirty'
114         build(config, live_server=live_server, dirty=dirty)
115         return config
116 
117     try:
118         # Perform the initial build
119         config = builder()
120 
121         host, port = config['dev_addr']
122 
123         if livereload in ['livereload', 'dirty']:
124             _livereload(host, port, config, builder, site_dir)
125         else:
126             _static_server(host, port, site_dir)
127     finally:
128         shutil.rmtree(site_dir)
129
```
--- 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()

```

diff --git a/mkdocs/commands/serve.py b/mkdocs/commands/serve.py
--- a/mkdocs/commands/serve.py
+++ b/mkdocs/commands/serve.py
@@ -3,6 +3,7 @@
 import logging
 import shutil
 import tempfile
+import sys
 
 from os.path import isfile, join
 from mkdocs.commands.build import build
@@ -11,6 +12,26 @@
 log = logging.getLogger(__name__)
 
 
+def _init_asyncio_patch():
+    """
+    Select compatible event loop for Tornado 5+.
+
+    As of Python 3.8, the default event loop on Windows is `proactor`,
+    however Tornado requires the old default "selector" event loop.
+    As Tornado has decided to leave this to users to set, MkDocs needs
+    to set it. See https://github.com/tornadoweb/tornado/issues/2608.
+    """
+    if sys.platform.startswith("win") and sys.version_info >= (3, 8):
+        import asyncio
+        try:
+            from asyncio import WindowsSelectorEventLoopPolicy
+        except ImportError:
+            pass  # Can't assign a policy which doesn't exist.
+        else:
+            if not isinstance(asyncio.get_event_loop_policy(), WindowsSelectorEventLoopPolicy):
+                asyncio.set_event_loop_policy(WindowsSelectorEventLoopPolicy())
+
+
 def _get_handler(site_dir, StaticFileHandler):
 
     from tornado.template import Loader
@@ -33,6 +54,7 @@
 
     # We are importing here for anyone that has issues with livereload. Even if
     # this fails, the --no-livereload alternative should still work.
+    _init_asyncio_patch()
     from livereload import Server
     import livereload.handlers
 
@@ -62,6 +84,7 @@
 
     # Importing here to seperate the code paths from the --livereload
     # alternative.
+    _init_asyncio_patch()
     from tornado import ioloop
     from tornado import web

{"golden_diff": "diff --git a/mkdocs/commands/serve.py b/mkdocs/commands/serve.py\n--- a/mkdocs/commands/serve.py\n+++ b/mkdocs/commands/serve.py\n@@ -3,6 +3,7 @@\n import logging\n import shutil\n import tempfile\n+import sys\n \n from os.path import isfile, join\n from mkdocs.commands.build import build\n@@ -11,6 +12,26 @@\n log = logging.getLogger(__name__)\n \n \n+def _init_asyncio_patch():\n+    \"\"\"\n+    Select compatible event loop for Tornado 5+.\n+\n+    As of Python 3.8, the default event loop on Windows is `proactor`,\n+    however Tornado requires the old default \"selector\" event loop.\n+    As Tornado has decided to leave this to users to set, MkDocs needs\n+    to set it. See https://github.com/tornadoweb/tornado/issues/2608.\n+    \"\"\"\n+    if sys.platform.startswith(\"win\") and sys.version_info >= (3, 8):\n+        import asyncio\n+        try:\n+            from asyncio import WindowsSelectorEventLoopPolicy\n+        except ImportError:\n+            pass  # Can't assign a policy which doesn't exist.\n+        else:\n+            if not isinstance(asyncio.get_event_loop_policy(), WindowsSelectorEventLoopPolicy):\n+                asyncio.set_event_loop_policy(WindowsSelectorEventLoopPolicy())\n+\n+\n def _get_handler(site_dir, StaticFileHandler):\n \n     from tornado.template import Loader\n@@ -33,6 +54,7 @@\n \n     # We are importing here for anyone that has issues with livereload. Even if\n     # this fails, the --no-livereload alternative should still work.\n+    _init_asyncio_patch()\n     from livereload import Server\n     import livereload.handlers\n \n@@ -62,6 +84,7 @@\n \n     # Importing here to seperate the code paths from the --livereload\n     # alternative.\n+    _init_asyncio_patch()\n     from tornado import ioloop\n     from tornado import web\n", "issue": "Asyncio NotImplemented Error after Python 3.8.0\nUsing a new install of Python 3.8.0, pip installed latest version of MkDocs, and then tried to run `mkdocs serve`, which encountered the below error. \r\n\r\nI tried again on a new docs directory (`mkdocs new testing`), but encountered the same issue again. \r\n\r\nPython version: 3.8.0\r\nOS: Windows 10 Pro v1709\r\n\r\nerror:\r\n```\r\nC:\\dev\\testing\r\n\u03bb  mkdocs serve\r\nINFO    -  Building documentation...\r\nINFO    -  Cleaning site directory\r\n[I 191017 14:49:48 server:296] Serving on http://127.0.0.1:8000\r\nTraceback (most recent call last):\r\n  File \"c:\\users\\aleksandr.skobelev\\appdata\\local\\programs\\python\\python38\\lib\\runpy.py\", line 192, in _run_module_as_main\r\n    return _run_code(code, main_globals, None,\r\n  File \"c:\\users\\aleksandr.skobelev\\appdata\\local\\programs\\python\\python38\\lib\\runpy.py\", line 85, in _run_code\r\n    exec(code, run_globals)\r\n  File \"C:\\Users\\aleksandr.skobelev\\AppData\\Local\\Programs\\Python\\Python38\\Scripts\\mkdocs.exe\\__main__.py\", line 9, in <module>\r\n  File \"c:\\users\\aleksandr.skobelev\\appdata\\local\\programs\\python\\python38\\lib\\site-packages\\click\\core.py\", line 764, in __call__\r\n    return self.main(*args, **kwargs)\r\n  File \"c:\\users\\aleksandr.skobelev\\appdata\\local\\programs\\python\\python38\\lib\\site-packages\\click\\core.py\", line 717, in main\r\n    rv = self.invoke(ctx)\r\n  File \"c:\\users\\aleksandr.skobelev\\appdata\\local\\programs\\python\\python38\\lib\\site-packages\\click\\core.py\", line 1137, in invoke\r\n    return _process_result(sub_ctx.command.invoke(sub_ctx))\r\n  File \"c:\\users\\aleksandr.skobelev\\appdata\\local\\programs\\python\\python38\\lib\\site-packages\\click\\core.py\", line 956, in invoke\r\n    return ctx.invoke(self.callback, **ctx.params)\r\n  File \"c:\\users\\aleksandr.skobelev\\appdata\\local\\programs\\python\\python38\\lib\\site-packages\\click\\core.py\", line 555, in invoke\r\n    return callback(*args, **kwargs)\r\n  File \"c:\\users\\aleksandr.skobelev\\appdata\\local\\programs\\python\\python38\\lib\\site-packages\\mkdocs\\__main__.py\", line 128, in serve_command\r\n    serve.serve(\r\n  File \"c:\\users\\aleksandr.skobelev\\appdata\\local\\programs\\python\\python38\\lib\\site-packages\\mkdocs\\commands\\serve.py\", line 124, in serve\r\n    _livereload(host, port, config, builder, site_dir)\r\n  File \"c:\\users\\aleksandr.skobelev\\appdata\\local\\programs\\python\\python38\\lib\\site-packages\\mkdocs\\commands\\serve.py\", line 58, in _livereload\r\n    server.serve(root=site_dir, host=host, port=port, restart_delay=0)\r\n  File \"c:\\users\\aleksandr.skobelev\\appdata\\local\\programs\\python\\python38\\lib\\site-packages\\livereload\\server.py\", line 298, in serve\r\n    self.application(\r\n  File \"c:\\users\\aleksandr.skobelev\\appdata\\local\\programs\\python\\python38\\lib\\site-packages\\livereload\\server.py\", line 253, in application\r\n    app.listen(port, address=host)\r\n  File \"c:\\users\\aleksandr.skobelev\\appdata\\local\\programs\\python\\python38\\lib\\site-packages\\tornado\\web.py\", line 2112, in listen\r\n    server.listen(port, address)\r\n  File \"c:\\users\\aleksandr.skobelev\\appdata\\local\\programs\\python\\python38\\lib\\site-packages\\tornado\\tcpserver.py\", line 152, in listen\r\n    self.add_sockets(sockets)\r\n  File \"c:\\users\\aleksandr.skobelev\\appdata\\local\\programs\\python\\python38\\lib\\site-packages\\tornado\\tcpserver.py\", line 165, in add_sockets\r\n    self._handlers[sock.fileno()] = add_accept_handler(\r\n  File \"c:\\users\\aleksandr.skobelev\\appdata\\local\\programs\\python\\python38\\lib\\site-packages\\tornado\\netutil.py\", line 279, in add_accept_handler\r\n    io_loop.add_handler(sock, accept_handler, IOLoop.READ)\r\n  File \"c:\\users\\aleksandr.skobelev\\appdata\\local\\programs\\python\\python38\\lib\\site-packages\\tornado\\platform\\asyncio.py\", line 99, in add_handler\r\n    self.asyncio_loop.add_reader(fd, self._handle_events, fd, IOLoop.READ)\r\n  File \"c:\\users\\aleksandr.skobelev\\appdata\\local\\programs\\python\\python38\\lib\\asyncio\\events.py\", line 501, in add_reader\r\n    raise NotImplementedError\r\nNotImplementedError\r\n```\n", "before_files": [{"content": "from __future__ import unicode_literals\n\nimport logging\nimport shutil\nimport tempfile\n\nfrom os.path import isfile, join\nfrom mkdocs.commands.build import build\nfrom mkdocs.config import load_config\n\nlog = logging.getLogger(__name__)\n\n\ndef _get_handler(site_dir, StaticFileHandler):\n\n    from tornado.template import Loader\n\n    class WebHandler(StaticFileHandler):\n\n        def write_error(self, status_code, **kwargs):\n\n            if status_code in (404, 500):\n                error_page = '{}.html'.format(status_code)\n                if isfile(join(site_dir, error_page)):\n                    self.write(Loader(site_dir).load(error_page).generate())\n                else:\n                    super(WebHandler, self).write_error(status_code, **kwargs)\n\n    return WebHandler\n\n\ndef _livereload(host, port, config, builder, site_dir):\n\n    # We are importing here for anyone that has issues with livereload. Even if\n    # this fails, the --no-livereload alternative should still work.\n    from livereload import Server\n    import livereload.handlers\n\n    class LiveReloadServer(Server):\n\n        def get_web_handlers(self, script):\n            handlers = super(LiveReloadServer, self).get_web_handlers(script)\n            # replace livereload handler\n            return [(handlers[0][0], _get_handler(site_dir, livereload.handlers.StaticFileHandler), handlers[0][2],)]\n\n    server = LiveReloadServer()\n\n    # Watch the documentation files, the config file and the theme files.\n    server.watch(config['docs_dir'], builder)\n    server.watch(config['config_file_path'], builder)\n\n    for d in config['theme'].dirs:\n        server.watch(d, builder)\n\n    # Run `serve` plugin events.\n    server = config['plugins'].run_event('serve', server, config=config)\n\n    server.serve(root=site_dir, host=host, port=port, restart_delay=0)\n\n\ndef _static_server(host, port, site_dir):\n\n    # Importing here to seperate the code paths from the --livereload\n    # alternative.\n    from tornado import ioloop\n    from tornado import web\n\n    application = web.Application([\n        (r\"/(.*)\", _get_handler(site_dir, web.StaticFileHandler), {\n            \"path\": site_dir,\n            \"default_filename\": \"index.html\"\n        }),\n    ])\n    application.listen(port=port, address=host)\n\n    log.info('Running at: http://%s:%s/', host, port)\n    log.info('Hold ctrl+c to quit.')\n    try:\n        ioloop.IOLoop.instance().start()\n    except KeyboardInterrupt:\n        log.info('Stopping server...')\n\n\ndef serve(config_file=None, dev_addr=None, strict=None, theme=None,\n          theme_dir=None, livereload='livereload'):\n    \"\"\"\n    Start the MkDocs development server\n\n    By default it will serve the documentation on http://localhost:8000/ and\n    it will rebuild the documentation and refresh the page automatically\n    whenever a file is edited.\n    \"\"\"\n\n    # Create a temporary build directory, and set some options to serve it\n    # PY2 returns a byte string by default. The Unicode prefix ensures a Unicode\n    # string is returned. And it makes MkDocs temp dirs easier to identify.\n    site_dir = tempfile.mkdtemp(prefix='mkdocs_')\n\n    def builder():\n        log.info(\"Building documentation...\")\n        config = load_config(\n            config_file=config_file,\n            dev_addr=dev_addr,\n            strict=strict,\n            theme=theme,\n            theme_dir=theme_dir,\n            site_dir=site_dir\n        )\n        # Override a few config settings after validation\n        config['site_url'] = 'http://{0}/'.format(config['dev_addr'])\n\n        live_server = livereload in ['dirty', 'livereload']\n        dirty = livereload == 'dirty'\n        build(config, live_server=live_server, dirty=dirty)\n        return config\n\n    try:\n        # Perform the initial build\n        config = builder()\n\n        host, port = config['dev_addr']\n\n        if livereload in ['livereload', 'dirty']:\n            _livereload(host, port, config, builder, site_dir)\n        else:\n            _static_server(host, port, site_dir)\n    finally:\n        shutil.rmtree(site_dir)\n", "path": "mkdocs/commands/serve.py"}], "after_files": [{"content": "from __future__ import unicode_literals\n\nimport logging\nimport shutil\nimport tempfile\nimport sys\n\nfrom os.path import isfile, join\nfrom mkdocs.commands.build import build\nfrom mkdocs.config import load_config\n\nlog = logging.getLogger(__name__)\n\n\ndef _init_asyncio_patch():\n    \"\"\"\n    Select compatible event loop for Tornado 5+.\n\n    As of Python 3.8, the default event loop on Windows is `proactor`,\n    however Tornado requires the old default \"selector\" event loop.\n    As Tornado has decided to leave this to users to set, MkDocs needs\n    to set it. See https://github.com/tornadoweb/tornado/issues/2608.\n    \"\"\"\n    if sys.platform.startswith(\"win\") and sys.version_info >= (3, 8):\n        import asyncio\n        try:\n            from asyncio import WindowsSelectorEventLoopPolicy\n        except ImportError:\n            pass  # Can't assign a policy which doesn't exist.\n        else:\n            if not isinstance(asyncio.get_event_loop_policy(), WindowsSelectorEventLoopPolicy):\n                asyncio.set_event_loop_policy(WindowsSelectorEventLoopPolicy())\n\n\ndef _get_handler(site_dir, StaticFileHandler):\n\n    from tornado.template import Loader\n\n    class WebHandler(StaticFileHandler):\n\n        def write_error(self, status_code, **kwargs):\n\n            if status_code in (404, 500):\n                error_page = '{}.html'.format(status_code)\n                if isfile(join(site_dir, error_page)):\n                    self.write(Loader(site_dir).load(error_page).generate())\n                else:\n                    super(WebHandler, self).write_error(status_code, **kwargs)\n\n    return WebHandler\n\n\ndef _livereload(host, port, config, builder, site_dir):\n\n    # We are importing here for anyone that has issues with livereload. Even if\n    # this fails, the --no-livereload alternative should still work.\n    _init_asyncio_patch()\n    from livereload import Server\n    import livereload.handlers\n\n    class LiveReloadServer(Server):\n\n        def get_web_handlers(self, script):\n            handlers = super(LiveReloadServer, self).get_web_handlers(script)\n            # replace livereload handler\n            return [(handlers[0][0], _get_handler(site_dir, livereload.handlers.StaticFileHandler), handlers[0][2],)]\n\n    server = LiveReloadServer()\n\n    # Watch the documentation files, the config file and the theme files.\n    server.watch(config['docs_dir'], builder)\n    server.watch(config['config_file_path'], builder)\n\n    for d in config['theme'].dirs:\n        server.watch(d, builder)\n\n    # Run `serve` plugin events.\n    server = config['plugins'].run_event('serve', server, config=config)\n\n    server.serve(root=site_dir, host=host, port=port, restart_delay=0)\n\n\ndef _static_server(host, port, site_dir):\n\n    # Importing here to seperate the code paths from the --livereload\n    # alternative.\n    _init_asyncio_patch()\n    from tornado import ioloop\n    from tornado import web\n\n    application = web.Application([\n        (r\"/(.*)\", _get_handler(site_dir, web.StaticFileHandler), {\n            \"path\": site_dir,\n            \"default_filename\": \"index.html\"\n        }),\n    ])\n    application.listen(port=port, address=host)\n\n    log.info('Running at: http://%s:%s/', host, port)\n    log.info('Hold ctrl+c to quit.')\n    try:\n        ioloop.IOLoop.instance().start()\n    except KeyboardInterrupt:\n        log.info('Stopping server...')\n\n\ndef serve(config_file=None, dev_addr=None, strict=None, theme=None,\n          theme_dir=None, livereload='livereload'):\n    \"\"\"\n    Start the MkDocs development server\n\n    By default it will serve the documentation on http://localhost:8000/ and\n    it will rebuild the documentation and refresh the page automatically\n    whenever a file is edited.\n    \"\"\"\n\n    # Create a temporary build directory, and set some options to serve it\n    # PY2 returns a byte string by default. The Unicode prefix ensures a Unicode\n    # string is returned. And it makes MkDocs temp dirs easier to identify.\n    site_dir = tempfile.mkdtemp(prefix='mkdocs_')\n\n    def builder():\n        log.info(\"Building documentation...\")\n        config = load_config(\n            config_file=config_file,\n            dev_addr=dev_addr,\n            strict=strict,\n            theme=theme,\n            theme_dir=theme_dir,\n            site_dir=site_dir\n        )\n        # Override a few config settings after validation\n        config['site_url'] = 'http://{0}/'.format(config['dev_addr'])\n\n        live_server = livereload in ['dirty', 'livereload']\n        dirty = livereload == 'dirty'\n        build(config, live_server=live_server, dirty=dirty)\n        return config\n\n    try:\n        # Perform the initial build\n        config = builder()\n\n        host, port = config['dev_addr']\n\n        if livereload in ['livereload', 'dirty']:\n            _livereload(host, port, config, builder, site_dir)\n        else:\n            _static_server(host, port, site_dir)\n    finally:\n        shutil.rmtree(site_dir)\n", "path": "mkdocs/commands/serve.py"}]}