web_server - css_include and js_include: add new options and example (#459)

* add new options and example

* update docs

* add suggested hint about inlineing files

* no html entities

* files are now served on separate urls
This commit is contained in:
Elkropac 2020-02-20 13:06:26 +01:00 committed by GitHub
parent d439c2bfa5
commit 69b39e06cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 21 additions and 2 deletions

View File

@ -35,9 +35,15 @@ Configuration variables:
- **port** (*Optional*, int): The port the web server should open its socket on.
- **css_url** (*Optional*, url): The URL that should be used for the CSS stylesheet. Defaults
to https://esphome.io/_static/webserver-v1.min.css (updates will go to ``v2``, ``v3``, etc).
to https://esphome.io/_static/webserver-v1.min.css (updates will go to ``v2``, ``v3``, etc). Can be set to empty string.
- **css_include** (*Optional*, local file): Path to local file to be included in web server index page.
Contents of this file will be served as ``/0.css`` and used as CSS stylesheet by internal webserver.
Useful when building device without internet access, where you want to use built-in AP and webserver.
- **js_url** (*Optional*, url): The URL that should be used for the JS script. Defaults
to https://esphome.io/_static/webserver-v1.min.js.
to https://esphome.io/_static/webserver-v1.min.js. Can be set to empty string.
- **js_include** (*Optional*, local file): Path to local file to be included in web server index page.
Contents of this file will be served as ``/0.js`` and used as JS script by internal webserver.
Useful when building device without internet access, where you want to use built-in AP and webserver.
- **auth** (*Optional*): Enables basic authentication with username and password.
- **username** (**Required**, string): The username to use for authentication.
@ -58,6 +64,19 @@ Configuration variables:
username: admin
password: !secret web_server_password
Example web_server configuration with CSS and JS included from esphome-docs.
CSS and JS URL's are set to empty value, so no internet access is needed for this device to show it's web interface.
.. code-block:: yaml
# Example configuration entry
web_server:
port: 80
css_include: "../../../esphome-docs/_static/webserver-v1.min.css"
css_url: ""
js_include: "../../../esphome-docs/_static/webserver-v1.min.js"
js_url: ""
See Also
--------