diff --git a/homeassistant/components/frontend/__init__.py b/homeassistant/components/frontend/__init__.py
index b5446b7236c..e757ac43e69 100644
--- a/homeassistant/components/frontend/__init__.py
+++ b/homeassistant/components/frontend/__init__.py
@@ -15,6 +15,8 @@ from homeassistant.const import URL_ROOT, HTTP_OK
DOMAIN = 'frontend'
DEPENDENCIES = ['api']
+INDEX_PATH = os.path.join(os.path.dirname(__file__), 'index.html.template')
+
_LOGGER = logging.getLogger(__name__)
@@ -40,10 +42,6 @@ def setup(hass, config):
def _handle_get_root(handler, path_match, data):
""" Renders the debug interface. """
- def write(txt):
- """ Helper to write text to the output. """
- handler.wfile.write((txt + "\n").encode("UTF-8"))
-
handler.send_response(HTTP_OK)
handler.send_header('Content-type', 'text/html; charset=utf-8')
handler.end_headers()
@@ -54,28 +52,16 @@ def _handle_get_root(handler, path_match, data):
app_url = "frontend-{}.html".format(version.VERSION)
# auto login if no password was set, else check api_password param
- auth = (handler.server.api_password if handler.server.no_password_set
+ auth = ('no_password_set' if handler.server.no_password_set
else data.get('api_password', ''))
- write((""
- ""
- "
Home Assistant"
- ""
- ""
- ""
- ""
- ""
- ""
- ""
- "Initializing Home Assistant
"
- ""
- ""
- ""
- "").format(app_url, auth))
+ with open(INDEX_PATH) as template_file:
+ template_html = template_file.read()
+
+ template_html = template_html.replace('{{ app_url }}', app_url)
+ template_html = template_html.replace('{{ auth }}', auth)
+
+ handler.wfile.write(template_html.encode("UTF-8"))
def _handle_get_static(handler, path_match, data):
diff --git a/homeassistant/components/frontend/index.html.template b/homeassistant/components/frontend/index.html.template
new file mode 100644
index 00000000000..c4da4f0369d
--- /dev/null
+++ b/homeassistant/components/frontend/index.html.template
@@ -0,0 +1,28 @@
+
+
+
+
+ Home Assistant
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Initializing Home Assistant
+
+
+
+
+
diff --git a/homeassistant/components/frontend/www_static/manifest.json b/homeassistant/components/frontend/www_static/manifest.json
new file mode 100644
index 00000000000..14d6eaba900
--- /dev/null
+++ b/homeassistant/components/frontend/www_static/manifest.json
@@ -0,0 +1,15 @@
+{
+ "name": "Home Assistant",
+ "short_name": "Home Assist",
+ "start_url": "/",
+ "display": "standalone",
+ "orientation": "portrait",
+ "icons": [
+ {
+ "src": "\/static\/favicon-192x192.png",
+ "sizes": "192x192",
+ "type": "image\/png",
+ "density": "4.0"
+ }
+ ]
+}
diff --git a/homeassistant/components/http/__init__.py b/homeassistant/components/http.py
similarity index 98%
rename from homeassistant/components/http/__init__.py
rename to homeassistant/components/http.py
index ae19d97eb9a..9539b1e45ee 100644
--- a/homeassistant/components/http/__init__.py
+++ b/homeassistant/components/http.py
@@ -341,17 +341,7 @@ class RequestHandler(SimpleHTTPRequestHandler):
self.send_response(HTTP_OK)
self.send_header(HTTP_HEADER_CONTENT_TYPE, content_type)
- # Add cache if not development
- if not self.server.development:
- # 1 year in seconds
- cache_time = 365 * 86400
-
- self.send_header(
- HTTP_HEADER_CACHE_CONTROL,
- "public, max-age={}".format(cache_time))
- self.send_header(
- HTTP_HEADER_EXPIRES,
- self.date_time_string(time.time()+cache_time))
+ self.set_cache_header()
if do_gzip:
gzip_data = gzip.compress(inp.read())
@@ -374,3 +364,16 @@ class RequestHandler(SimpleHTTPRequestHandler):
else:
self.copyfile(inp, self.wfile)
+
+ def set_cache_header(self):
+ """ Add cache headers if not in development """
+ if not self.server.development:
+ # 1 year in seconds
+ cache_time = 365 * 86400
+
+ self.send_header(
+ HTTP_HEADER_CACHE_CONTROL,
+ "public, max-age={}".format(cache_time))
+ self.send_header(
+ HTTP_HEADER_EXPIRES,
+ self.date_time_string(time.time()+cache_time))