We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
If main.py is run by bokeh serve, warn about running with directory name instead
Lots of reports of people running, e.g.
```
bokeh serve --show crossfilter/main.py
```
Which prevents all the features of "directory style" apps from being enabled. 

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `bokeh/command/util.py`
Content:
```
1 ''' Provide utility functions for implementing the Bokeh command.
2 
3 '''
4 from __future__ import print_function
5 
6 import os
7 import sys
8 
9 from bokeh.application import Application
10 from bokeh.application.handlers import ScriptHandler, DirectoryHandler, NotebookHandler
11 
12 def die(message):
13     ''' Print an error message and exit.
14 
15     Args:
16         message (str) : error message to print
17 
18     '''
19     print(message, file=sys.stderr)
20     sys.exit(1)
21 
22 def build_single_handler_application(path, argv=None):
23     ''' Return a Bokeh application built using a single handler for a file
24     or directory.
25 
26     Args:
27         path (str) : path to a file or directory for creating a Bokeh
28             application.
29         argv (seq[str], optional) : command line arguments to pass to the
30             application handler
31 
32     Returns:
33         Application
34 
35     Raises:
36         RuntimeError
37 
38     '''
39     argv = argv or []
40     path = os.path.abspath(path)
41     if os.path.isdir(path):
42         handler = DirectoryHandler(filename=path, argv=argv)
43     else:
44         if path.endswith(".ipynb"):
45             handler = NotebookHandler(filename=path, argv=argv)
46         elif path.endswith(".py"):
47             handler = ScriptHandler(filename=path, argv=argv)
48         else:
49             raise ValueError("Expected a '.py' script or '.ipynb' notebook, got: '%s'" % path)
50 
51     if handler.failed:
52         raise RuntimeError("Error loading %s:\n\n%s\n%s " % (path, handler.error, handler.error_detail))
53 
54     application = Application(handler)
55 
56     return application
57 
58 def build_single_handler_applications(paths, argvs=None):
59     ''' Return a dictionary mapping routes to Bokeh applications built using
60     single handlers, for specified files or directories.
61 
62     Args:
63         path (seq[str]) : paths to files or directories for creating Bokeh
64             applications.
65         argvs (dict[str, list[str]], optional) : mapping of paths to command
66             line arguments to pass to the handler for each path
67 
68     Returns:
69         dict[str, Application]
70 
71     Raises:
72         RuntimeError
73 
74     '''
75     applications = {}
76     argvs = {} or argvs
77 
78     for path in paths:
79         application = build_single_handler_application(path, argvs.get(path, []))
80 
81         route = application.handlers[0].url_path()
82 
83         if not route:
84             if '/' in applications:
85                 raise RuntimeError("Don't know the URL path to use for %s" % (path))
86             route = '/'
87         applications[route] = application
88 
89     return applications
90
```
--- 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/bokeh/command/util.py b/bokeh/command/util.py
--- a/bokeh/command/util.py
+++ b/bokeh/command/util.py
@@ -5,6 +5,7 @@
 
 import os
 import sys
+import warnings
 
 from bokeh.application import Application
 from bokeh.application.handlers import ScriptHandler, DirectoryHandler, NotebookHandler
@@ -19,6 +20,16 @@
     print(message, file=sys.stderr)
     sys.exit(1)
 
+DIRSTYLE_MAIN_WARNING = """
+It looks like you might be running the main.py of a directory app directly.
+If this is the case, to enable the features of directory style apps, you must
+call "bokeh serve" on the directory instead. For example:
+
+    bokeh serve my_app_dir/
+
+If this is not the case, renaming main.py will supress this warning.
+"""
+
 def build_single_handler_application(path, argv=None):
     ''' Return a Bokeh application built using a single handler for a file
     or directory.
@@ -44,6 +55,8 @@
         if path.endswith(".ipynb"):
             handler = NotebookHandler(filename=path, argv=argv)
         elif path.endswith(".py"):
+            if path.endswith("main.py"):
+                warnings.warn(DIRSTYLE_MAIN_WARNING)
             handler = ScriptHandler(filename=path, argv=argv)
         else:
             raise ValueError("Expected a '.py' script or '.ipynb' notebook, got: '%s'" % path)

{"golden_diff": "diff --git a/bokeh/command/util.py b/bokeh/command/util.py\n--- a/bokeh/command/util.py\n+++ b/bokeh/command/util.py\n@@ -5,6 +5,7 @@\n \n import os\n import sys\n+import warnings\n \n from bokeh.application import Application\n from bokeh.application.handlers import ScriptHandler, DirectoryHandler, NotebookHandler\n@@ -19,6 +20,16 @@\n     print(message, file=sys.stderr)\n     sys.exit(1)\n \n+DIRSTYLE_MAIN_WARNING = \"\"\"\n+It looks like you might be running the main.py of a directory app directly.\n+If this is the case, to enable the features of directory style apps, you must\n+call \"bokeh serve\" on the directory instead. For example:\n+\n+    bokeh serve my_app_dir/\n+\n+If this is not the case, renaming main.py will supress this warning.\n+\"\"\"\n+\n def build_single_handler_application(path, argv=None):\n     ''' Return a Bokeh application built using a single handler for a file\n     or directory.\n@@ -44,6 +55,8 @@\n         if path.endswith(\".ipynb\"):\n             handler = NotebookHandler(filename=path, argv=argv)\n         elif path.endswith(\".py\"):\n+            if path.endswith(\"main.py\"):\n+                warnings.warn(DIRSTYLE_MAIN_WARNING)\n             handler = ScriptHandler(filename=path, argv=argv)\n         else:\n             raise ValueError(\"Expected a '.py' script or '.ipynb' notebook, got: '%s'\" % path)\n", "issue": "If main.py is run by bokeh serve, warn about running with directory name instead\nLots of reports of people running, e.g.\r\n```\r\nbokeh serve --show crossfilter/main.py\r\n```\r\nWhich prevents all the features of \"directory style\" apps from being enabled. \n", "before_files": [{"content": "''' Provide utility functions for implementing the Bokeh command.\n\n'''\nfrom __future__ import print_function\n\nimport os\nimport sys\n\nfrom bokeh.application import Application\nfrom bokeh.application.handlers import ScriptHandler, DirectoryHandler, NotebookHandler\n\ndef die(message):\n    ''' Print an error message and exit.\n\n    Args:\n        message (str) : error message to print\n\n    '''\n    print(message, file=sys.stderr)\n    sys.exit(1)\n\ndef build_single_handler_application(path, argv=None):\n    ''' Return a Bokeh application built using a single handler for a file\n    or directory.\n\n    Args:\n        path (str) : path to a file or directory for creating a Bokeh\n            application.\n        argv (seq[str], optional) : command line arguments to pass to the\n            application handler\n\n    Returns:\n        Application\n\n    Raises:\n        RuntimeError\n\n    '''\n    argv = argv or []\n    path = os.path.abspath(path)\n    if os.path.isdir(path):\n        handler = DirectoryHandler(filename=path, argv=argv)\n    else:\n        if path.endswith(\".ipynb\"):\n            handler = NotebookHandler(filename=path, argv=argv)\n        elif path.endswith(\".py\"):\n            handler = ScriptHandler(filename=path, argv=argv)\n        else:\n            raise ValueError(\"Expected a '.py' script or '.ipynb' notebook, got: '%s'\" % path)\n\n    if handler.failed:\n        raise RuntimeError(\"Error loading %s:\\n\\n%s\\n%s \" % (path, handler.error, handler.error_detail))\n\n    application = Application(handler)\n\n    return application\n\ndef build_single_handler_applications(paths, argvs=None):\n    ''' Return a dictionary mapping routes to Bokeh applications built using\n    single handlers, for specified files or directories.\n\n    Args:\n        path (seq[str]) : paths to files or directories for creating Bokeh\n            applications.\n        argvs (dict[str, list[str]], optional) : mapping of paths to command\n            line arguments to pass to the handler for each path\n\n    Returns:\n        dict[str, Application]\n\n    Raises:\n        RuntimeError\n\n    '''\n    applications = {}\n    argvs = {} or argvs\n\n    for path in paths:\n        application = build_single_handler_application(path, argvs.get(path, []))\n\n        route = application.handlers[0].url_path()\n\n        if not route:\n            if '/' in applications:\n                raise RuntimeError(\"Don't know the URL path to use for %s\" % (path))\n            route = '/'\n        applications[route] = application\n\n    return applications\n", "path": "bokeh/command/util.py"}], "after_files": [{"content": "''' Provide utility functions for implementing the Bokeh command.\n\n'''\nfrom __future__ import print_function\n\nimport os\nimport sys\nimport warnings\n\nfrom bokeh.application import Application\nfrom bokeh.application.handlers import ScriptHandler, DirectoryHandler, NotebookHandler\n\ndef die(message):\n    ''' Print an error message and exit.\n\n    Args:\n        message (str) : error message to print\n\n    '''\n    print(message, file=sys.stderr)\n    sys.exit(1)\n\nDIRSTYLE_MAIN_WARNING = \"\"\"\nIt looks like you might be running the main.py of a directory app directly.\nIf this is the case, to enable the features of directory style apps, you must\ncall \"bokeh serve\" on the directory instead. For example:\n\n    bokeh serve my_app_dir/\n\nIf this is not the case, renaming main.py will supress this warning.\n\"\"\"\n\ndef build_single_handler_application(path, argv=None):\n    ''' Return a Bokeh application built using a single handler for a file\n    or directory.\n\n    Args:\n        path (str) : path to a file or directory for creating a Bokeh\n            application.\n        argv (seq[str], optional) : command line arguments to pass to the\n            application handler\n\n    Returns:\n        Application\n\n    Raises:\n        RuntimeError\n\n    '''\n    argv = argv or []\n    path = os.path.abspath(path)\n    if os.path.isdir(path):\n        handler = DirectoryHandler(filename=path, argv=argv)\n    else:\n        if path.endswith(\".ipynb\"):\n            handler = NotebookHandler(filename=path, argv=argv)\n        elif path.endswith(\".py\"):\n            if path.endswith(\"main.py\"):\n                warnings.warn(DIRSTYLE_MAIN_WARNING)\n            handler = ScriptHandler(filename=path, argv=argv)\n        else:\n            raise ValueError(\"Expected a '.py' script or '.ipynb' notebook, got: '%s'\" % path)\n\n    if handler.failed:\n        raise RuntimeError(\"Error loading %s:\\n\\n%s\\n%s \" % (path, handler.error, handler.error_detail))\n\n    application = Application(handler)\n\n    return application\n\ndef build_single_handler_applications(paths, argvs=None):\n    ''' Return a dictionary mapping routes to Bokeh applications built using\n    single handlers, for specified files or directories.\n\n    Args:\n        path (seq[str]) : paths to files or directories for creating Bokeh\n            applications.\n        argvs (dict[str, list[str]], optional) : mapping of paths to command\n            line arguments to pass to the handler for each path\n\n    Returns:\n        dict[str, Application]\n\n    Raises:\n        RuntimeError\n\n    '''\n    applications = {}\n    argvs = {} or argvs\n\n    for path in paths:\n        application = build_single_handler_application(path, argvs.get(path, []))\n\n        route = application.handlers[0].url_path()\n\n        if not route:\n            if '/' in applications:\n                raise RuntimeError(\"Don't know the URL path to use for %s\" % (path))\n            route = '/'\n        applications[route] = application\n\n    return applications\n", "path": "bokeh/command/util.py"}]}