Expose panel update (#482)

* Update __init__.py

* Update setup.py

* Update security.py

* Update setup.py

* Update __init__.py

* Update setup.py

* Update __init__.py
This commit is contained in:
Pascal Vizeli 2018-05-28 23:16:03 +02:00 committed by GitHub
parent bc0835963d
commit efb1a24b8f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 15 deletions

View File

@ -185,10 +185,11 @@ class RestAPI(CoreSysAttributes):
def _register_panel(self):
"""Register panel for homeassistant."""
def create_response(build_type):
panel_dir = Path(__file__).parent.joinpath("panel")
def create_response(panel_file):
"""Create a function to generate a response."""
path = Path(__file__).parent.joinpath(
f"panel/{build_type}.html")
path = panel_dir.joinpath(f"{panel_file!s}.html")
return lambda request: web.FileResponse(path)
# This route is for backwards compatibility with HA < 0.58
@ -202,10 +203,7 @@ class RestAPI(CoreSysAttributes):
])
# This route is for HA > 0.61
self.webapp.add_routes([
web.get('/app-es5/index.html', create_response('index')),
web.get('/app-es5/hassio-app.html', create_response('hassio-app')),
])
self.webapp.add_routes([web.static('/app-es5', panel_dir)])
async def start(self):
"""Run rest api webserver."""

View File

@ -35,11 +35,10 @@ class SecurityMiddleware(CoreSysAttributes):
_LOGGER.debug("Passthrough %s", request.path)
return await handler(request)
# Need to be removed later
# Unknown API access
if not hassio_token:
_LOGGER.warning("Invalid token for access %s", request.path)
request[REQUEST_FROM] = 'UNKNOWN'
return await handler(request)
raise HTTPUnauthorized()
# Home-Assistant
if hassio_token == self.sys_homeassistant.uuid:

View File

@ -40,13 +40,14 @@ setup(
],
include_package_data=True,
install_requires=[
'async_timeout==2.0.1',
'aiohttp==3.1.2',
'docker==3.2.0',
'attr==0.3.1',
'async_timeout==3.0.0',
'aiohttp==3.2.1',
'docker==3.3.0',
'colorlog==3.1.2',
'voluptuous==0.11.1',
'gitpython==2.1.8',
'pytz==2018.3',
'gitpython==2.1.10',
'pytz==2018.4',
'pyudev==0.21.0',
'pycryptodome==3.4.11'
]