mirror of
https://github.com/esphome/esphome.git
synced 2024-11-26 00:48:19 +01:00
Fix css/js file loading for webserver when esphome not executed form config directory (#2207)
This commit is contained in:
parent
94b28102f5
commit
b955527f6c
1 changed files with 5 additions and 3 deletions
|
@ -13,7 +13,7 @@ from esphome.const import (
|
||||||
CONF_USERNAME,
|
CONF_USERNAME,
|
||||||
CONF_PASSWORD,
|
CONF_PASSWORD,
|
||||||
)
|
)
|
||||||
from esphome.core import coroutine_with_priority
|
from esphome.core import CORE, coroutine_with_priority
|
||||||
|
|
||||||
AUTO_LOAD = ["json", "web_server_base"]
|
AUTO_LOAD = ["json", "web_server_base"]
|
||||||
|
|
||||||
|
@ -61,9 +61,11 @@ async def to_code(config):
|
||||||
cg.add(var.set_password(config[CONF_AUTH][CONF_PASSWORD]))
|
cg.add(var.set_password(config[CONF_AUTH][CONF_PASSWORD]))
|
||||||
if CONF_CSS_INCLUDE in config:
|
if CONF_CSS_INCLUDE in config:
|
||||||
cg.add_define("WEBSERVER_CSS_INCLUDE")
|
cg.add_define("WEBSERVER_CSS_INCLUDE")
|
||||||
with open(config[CONF_CSS_INCLUDE], "r") as myfile:
|
path = CORE.relative_config_path(config[CONF_CSS_INCLUDE])
|
||||||
|
with open(path, "r") as myfile:
|
||||||
cg.add(var.set_css_include(myfile.read()))
|
cg.add(var.set_css_include(myfile.read()))
|
||||||
if CONF_JS_INCLUDE in config:
|
if CONF_JS_INCLUDE in config:
|
||||||
cg.add_define("WEBSERVER_JS_INCLUDE")
|
cg.add_define("WEBSERVER_JS_INCLUDE")
|
||||||
with open(config[CONF_JS_INCLUDE], "r") as myfile:
|
path = CORE.relative_config_path(config[CONF_JS_INCLUDE])
|
||||||
|
with open(path, "r") as myfile:
|
||||||
cg.add(var.set_js_include(myfile.read()))
|
cg.add(var.set_js_include(myfile.read()))
|
||||||
|
|
Loading…
Reference in a new issue