@@ -59,7 +59,7 @@ Socket.IO servers to integrate easily into existing WSGI or ASGI applications::
5959Serving Static Files
6060--------------------
6161
62- This package offers the option to configure the serving of static files. This
62+ The Engine.IO server can be configured to serve static files to clients . This
6363is particularly useful to deliver HTML, CSS and JavaScript files to clients
6464when this package is used without a companion web framework.
6565
@@ -91,20 +91,38 @@ If desired, an explicit content type for a static file can be given as follows::
9191 '/': {'filename': 'latency.html', 'content_type': 'text/plain'},
9292 }
9393
94- Finally, it is also possible to configure an entire directory in a single rule,
95- so that all the files in it are served as static files::
94+ It is also possible to configure an entire directory in a single rule, so that all
95+ the files in it are served as static files::
9696
9797 static_files = {
9898 '/static': './public',
99- '/': './public/index.html',
10099 }
101100
102101In this example any files with URLs starting with ``/static `` will be served
103102directly from the ``public `` folder in the current directory, so for example,
104103the URL ``/static/index.html `` will return local file ``./public/index.html ``
105104and the URL ``/static/css/styles.css `` will return local file
106- ``./public/css/styles.css ``. The second rule creates a default mapping for the
107- ``index.html `` file when the root URL is requested.
105+ ``./public/css/styles.css ``.
106+
107+ If a URL that ends in a ``/ `` is requested, then a default filename of
108+ ``index.html `` is appended to it. In the previous example, a request for the
109+ ``/static/ `` URL would return local file ``./public/index.html ``. The default
110+ filename to serve for slash-ending URLs can be set in the static files
111+ dictionary with an empty key::
112+
113+ static_files = {
114+ '/static': './public',
115+ '': 'image.gif',
116+ }
117+
118+ With this configuration, a request for ``/static/ `` would return
119+ local file ``./public/image.gif ``. A non-standard content type can also be
120+ specified if needed::
121+
122+ static_files = {
123+ '/static': './public',
124+ '': {'filename': 'image.gif', 'content_type': 'text/plain'},
125+ }
108126
109127The static file configuration dictionary is given as the ``static_files ``
110128argument to the ``socketio.WSGIApp `` or ``socketio.ASGIApp `` classes::
0 commit comments