Django Hosts

The Smarter Framework supports multiple hosts using the django-hosts package.

This module defines the complete set of host patterns for the Smarter Framework,.

organized by logical group.

Web Console Hosts

Web Console Hosts

Host

Description

localhost:9357

For local development via http://localhost:9357/

127.0.0.1:9357

For local development via http://127.0.0.1:9357/

platform.example.com

Main production platform console.

alpha.platform.example.com

Alpha environment for the platform console.

beta.platform.example.com

Beta environment for the platform console.

next.platform.example.com

Next environment for the platform console.

API Subdomain Hosts

API Subdomain Hosts

Host

Description

api.localhost:9357

Local API endpoint for http://api.localhost:9357/

api.127.0.0.1:9357

Local API endpoint for http://api.127.0.0.1:9357/

api.example.com

Main production API endpoint.

alpha.api.example.com

Alpha environment for the API.

beta.api.example.com

Beta environment for the API.

next.api.example.com

Next environment for the API.

Named LLMClient Hosts

Named LLMClient Hosts

Host

Description

<llm_client_name>.<account_number>.api.example.com

Deployed named llm_client on production API.

<llm_client_name>.<account_number>.alpha.api.example.com

Deployed named llm_client on alpha API.

<llm_client_name>.<account_number>.beta.api.example.com

Deployed named llm_client on beta API.

<llm_client_name>.<account_number>.next.api.example.com

Deployed named llm_client on next API.

Each host pattern is mapped to the appropriate Django URL configuration for the console, API, or llm_client endpoints, and supports multiple environments for development, staging, and production.

 1
 2from django_hosts import host, patterns
 3
 4from smarter.common.conf import smarter_settings
 5from smarter.common.const import SmarterEnvironments
 6from smarter.urls import api as smarter_api_urls
 7from smarter.urls import console as smarter_console_urls
 8from smarter.urls import llm_clients as smarter_llm_clients_urls
 9
10host_patterns = patterns(
11    "",
12    # -------------------------------------------------------------------------
13    # web console
14    # -------------------------------------------------------------------------
15    host(r"localhost:9357", smarter_console_urls, name="localhost"),  # for http://localhost:9357/
16    host(r"127.0.0.1:9357", smarter_console_urls, name="127001"),  # for http://127.0.0.1:9357/
17    host(
18        rf"{smarter_settings.platform_subdomain}.{smarter_settings.root_domain}",
19        smarter_console_urls,
20        name=smarter_settings.platform_subdomain,
21    ),  # for https://platform.example.com/
22    host(
23        rf"{SmarterEnvironments.ALPHA}.{smarter_settings.platform_subdomain}.{smarter_settings.root_domain}",
24        smarter_console_urls,
25        name=f"{SmarterEnvironments.ALPHA}_{smarter_settings.platform_subdomain}",
26    ),  # for https://alpha.platform.example.com/
27    host(
28        rf"{SmarterEnvironments.BETA}.{smarter_settings.platform_subdomain}.{smarter_settings.root_domain}",
29        smarter_console_urls,
30        name=f"{SmarterEnvironments.BETA}_{smarter_settings.platform_subdomain}",
31    ),  # for https://beta.platform.example.com/
32    host(
33        rf"{SmarterEnvironments.NEXT}.{smarter_settings.platform_subdomain}.{smarter_settings.root_domain}",
34        smarter_console_urls,
35        name=f"{SmarterEnvironments.NEXT}_{smarter_settings.platform_subdomain}",
36    ),  # for https://next.platform.example.com/
37    # -------------------------------------------------------------------------
38    # API subdomains
39    # -------------------------------------------------------------------------
40    host(r"api.localhost:9357", smarter_api_urls, name="api_localhost"),  # for http://api.localhost:9357/
41    host(r"api.127.0.0.1:9357", smarter_api_urls, name="api_127001"),  # for http://api.127.0.0.1:9357/
42    host(
43        rf"{smarter_settings.api_subdomain}.{smarter_settings.root_domain}",
44        smarter_api_urls,
45        name=smarter_settings.api_subdomain,
46    ),  # for https://api.platform.example.com/
47    host(
48        rf"{SmarterEnvironments.ALPHA}.{smarter_settings.api_subdomain}.{smarter_settings.root_domain}",
49        smarter_api_urls,
50        name=f"{SmarterEnvironments.ALPHA}_{smarter_settings.api_subdomain}",
51    ),  # for https://alpha.api.platform.example.com/
52    host(
53        rf"{SmarterEnvironments.BETA}.{smarter_settings.api_subdomain}.{smarter_settings.root_domain}",
54        smarter_api_urls,
55        name=f"{SmarterEnvironments.BETA}_{smarter_settings.api_subdomain}",
56    ),  # for https://beta.api.platform.example.com/
57    host(
58        rf"{SmarterEnvironments.NEXT}.{smarter_settings.api_subdomain}.{smarter_settings.root_domain}",
59        smarter_api_urls,
60        name=f"{SmarterEnvironments.NEXT}_{smarter_settings.api_subdomain}",
61    ),  # for https://next.api.platform.example.com/
62    # -------------------------------------------------------------------------
63    # Deployed named LLMClients
64    # eg https://education.3141-5926-5359.alpha.api.example.com/
65    # -------------------------------------------------------------------------
66    host(
67        rf"(?P<llm_client_name>[\w\-]+)\.(?P<account_number>\d{{4}}-\d{{4}})\.{smarter_settings.api_subdomain}.{smarter_settings.root_domain}",
68        smarter_llm_clients_urls,
69        name="llm_client_named_api",
70    ),  # for https://<llm_client_name>.<account_number>.api.platform.example.com/
71    host(
72        rf"(?P<llm_client_name>[\w\-]+)\.(?P<account_number>\d{{4}}-\d{{4}})\.{SmarterEnvironments.ALPHA}.{smarter_settings.api_subdomain}.{smarter_settings.root_domain}",
73        smarter_llm_clients_urls,
74        name=f"llm_client_named_{SmarterEnvironments.ALPHA}_api",
75    ),  # for https://<llm_client_name>.<account_number>.alpha.api.platform.example.com/
76    host(
77        rf"(?P<llm_client_name>[\w\-]+)\.(?P<account_number>\d{{4}}-\d{{4}})\.{SmarterEnvironments.BETA}.{smarter_settings.api_subdomain}.{smarter_settings.root_domain}",
78        smarter_llm_clients_urls,
79        name=f"llm_client_named_{SmarterEnvironments.BETA}_api",
80    ),  # for https://<llm_client_name>.<account_number>.beta.api.platform.example.com/
81    host(
82        rf"(?P<llm_client_name>[\w\-]+)\.(?P<account_number>\d{{4}}-\d{{4}})\.{SmarterEnvironments.NEXT}.{smarter_settings.api_subdomain}.{smarter_settings.root_domain}",
83        smarter_llm_clients_urls,
84        name=f"llm_client_named_{SmarterEnvironments.NEXT}_api",
85    ),  # for https://<llm_client_name>.<account_number>.next.api.platform.example.com/
86)
87
88__all__ = ["host_patterns"]