Home Assistant Unofficial Reference 2024.12.1
homeassistant.components.http.HomeAssistantHTTP Class Reference

Public Member Functions

None __init__ (self, HomeAssistant hass, str|None ssl_certificate, str|None ssl_peer_certificate, str|None ssl_key, list[str]|None server_host, int server_port, list[IPv4Network|IPv6Network] trusted_proxies, str ssl_profile)
 
None async_initialize (self, *list[str] cors_origins, bool use_x_forwarded_for, int login_threshold, bool is_ban_enabled, bool use_x_frame_options)
 
None async_register_static_paths (self, Collection[StaticPathConfig] configs)
 
None register_redirect (self, str url, StrOrURL redirect_to, *type[HTTPRedirection] redirect_exc=HTTPMovedPermanently)
 
None register_static_path (self, str url_path, str path, bool cache_headers=True)
 
None register_view (self, HomeAssistantView|type[HomeAssistantView] view)
 
None start (self)
 
None stop (self)
 

Public Attributes

 app
 
 context
 
 hass
 
 runner
 
 server_host
 
 server_port
 
 site
 
 ssl_certificate
 
 ssl_key
 
 ssl_peer_certificate
 
 ssl_profile
 
 trusted_proxies
 

Private Member Functions

None _async_register_static_paths (self, Collection[StaticPathConfig] configs, dict[str, CachingStaticResource|web.StaticResource|None] resources)
 
ssl.SSLContext _create_emergency_ssl_context (self)
 
ssl.SSLContext|None _create_ssl_context (self)
 
dict[str, CachingStaticResource|web.StaticResource|None] _make_static_resources (self, Collection[StaticPathConfig] configs)
 

Detailed Description

HTTP server for Home Assistant.

Definition at line 345 of file __init__.py.

Constructor & Destructor Documentation

◆ __init__()

None homeassistant.components.http.HomeAssistantHTTP.__init__ (   self,
HomeAssistant  hass,
str | None  ssl_certificate,
str | None  ssl_peer_certificate,
str | None  ssl_key,
list[str] | None  server_host,
int  server_port,
list[IPv4Network | IPv6Network]  trusted_proxies,
str  ssl_profile 
)
Initialize the HTTP Home Assistant server.

Definition at line 348 of file __init__.py.

Member Function Documentation

◆ _async_register_static_paths()

None homeassistant.components.http.HomeAssistantHTTP._async_register_static_paths (   self,
Collection[StaticPathConfig configs,
dict[str, CachingStaticResource | web.StaticResource | None]  resources 
)
private
Register a folders or files to serve as a static path.

Definition at line 483 of file __init__.py.

◆ _create_emergency_ssl_context()

ssl.SSLContext homeassistant.components.http.HomeAssistantHTTP._create_emergency_ssl_context (   self)
private
Create an emergency ssl certificate so we can still startup.

Definition at line 570 of file __init__.py.

◆ _create_ssl_context()

ssl.SSLContext | None homeassistant.components.http.HomeAssistantHTTP._create_ssl_context (   self)
private

Definition at line 522 of file __init__.py.

◆ _make_static_resources()

dict[str, CachingStaticResource | web.StaticResource | None] homeassistant.components.http.HomeAssistantHTTP._make_static_resources (   self,
Collection[StaticPathConfig]   configs 
)
private
Create a list of static resources.

Definition at line 460 of file __init__.py.

◆ async_initialize()

None homeassistant.components.http.HomeAssistantHTTP.async_initialize (   self,
*list[str]  cors_origins,
bool  use_x_forwarded_for,
int  login_threshold,
bool  is_ban_enabled,
bool  use_x_frame_options 
)
Initialize the server.

Definition at line 380 of file __init__.py.

◆ async_register_static_paths()

None homeassistant.components.http.HomeAssistantHTTP.async_register_static_paths (   self,
Collection[StaticPathConfig]   configs 
)
Register a folder or file to serve as a static path.

Definition at line 473 of file __init__.py.

◆ register_redirect()

None homeassistant.components.http.HomeAssistantHTTP.register_redirect (   self,
str  url,
StrOrURL  redirect_to,
*type[HTTPRedirection]   redirect_exc = HTTPMovedPermanently 
)
Register a redirect with the server.

If given this must be either a string or callable. In case of a
callable it's called with the url adapter that triggered the match and
the values of the URL as keyword arguments and has to return the target
for the redirect, otherwise it has to be a string with placeholders in
rule syntax.

Definition at line 435 of file __init__.py.

◆ register_static_path()

None homeassistant.components.http.HomeAssistantHTTP.register_static_path (   self,
str  url_path,
str  path,
bool   cache_headers = True 
)
Register a folder or file to serve as a static path.

Definition at line 505 of file __init__.py.

◆ register_view()

None homeassistant.components.http.HomeAssistantHTTP.register_view (   self,
HomeAssistantView | type[HomeAssistantView]  view 
)
Register a view with the WSGI server.

The view argument must be a class that inherits from HomeAssistantView.
It is optional to instantiate it before registering; this method will
handle it either way.

Definition at line 414 of file __init__.py.

◆ start()

None homeassistant.components.http.HomeAssistantHTTP.start (   self)
Start the aiohttp server.

Definition at line 619 of file __init__.py.

◆ stop()

None homeassistant.components.http.HomeAssistantHTTP.stop (   self)
Stop the aiohttp server.

Definition at line 644 of file __init__.py.

Member Data Documentation

◆ app

homeassistant.components.http.HomeAssistantHTTP.app

Definition at line 360 of file __init__.py.

◆ context

homeassistant.components.http.HomeAssistantHTTP.context

Definition at line 410 of file __init__.py.

◆ hass

homeassistant.components.http.HomeAssistantHTTP.hass

Definition at line 368 of file __init__.py.

◆ runner

homeassistant.components.http.HomeAssistantHTTP.runner

Definition at line 627 of file __init__.py.

◆ server_host

homeassistant.components.http.HomeAssistantHTTP.server_host

Definition at line 372 of file __init__.py.

◆ server_port

homeassistant.components.http.HomeAssistantHTTP.server_port

Definition at line 373 of file __init__.py.

◆ site

homeassistant.components.http.HomeAssistantHTTP.site

Definition at line 632 of file __init__.py.

◆ ssl_certificate

homeassistant.components.http.HomeAssistantHTTP.ssl_certificate

Definition at line 369 of file __init__.py.

◆ ssl_key

homeassistant.components.http.HomeAssistantHTTP.ssl_key

Definition at line 371 of file __init__.py.

◆ ssl_peer_certificate

homeassistant.components.http.HomeAssistantHTTP.ssl_peer_certificate

Definition at line 370 of file __init__.py.

◆ ssl_profile

homeassistant.components.http.HomeAssistantHTTP.ssl_profile

Definition at line 375 of file __init__.py.

◆ trusted_proxies

homeassistant.components.http.HomeAssistantHTTP.trusted_proxies

Definition at line 374 of file __init__.py.


The documentation for this class was generated from the following file: