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
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
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
Host |
Description |
|---|---|
<llmclient_name>.<account_number>.api.example.com |
Deployed named llmclient on production API. |
<llmclient_name>.<account_number>.alpha.api.example.com |
Deployed named llmclient on alpha API. |
<llmclient_name>.<account_number>.beta.api.example.com |
Deployed named llmclient on beta API. |
<llmclient_name>.<account_number>.next.api.example.com |
Deployed named llmclient on next API. |
Each host pattern is mapped to the appropriate Django URL configuration for the console, API, or llmclient 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 llmclients as smarter_llmclients_urls
9
10API_DOMAIN = re.escape(f"{smarter_settings.api_subdomain}.{smarter_settings.root_domain}")
11"""The api domain, e.g. api.example.com, as a regular expression.
12
13Deployed LLMClients are its subdomains.
14"""
15
16host_patterns = patterns(
17 "",
18 # -------------------------------------------------------------------------
19 # web console
20 # -------------------------------------------------------------------------
21 host(r"localhost:9357", smarter_console_urls, name="localhost"), # for http://localhost:9357/
22 host(r"127.0.0.1:9357", smarter_console_urls, name="127001"), # for http://127.0.0.1:9357/
23 host(
24 rf"{smarter_settings.platform_subdomain}.{smarter_settings.root_domain}",
25 smarter_console_urls,
26 name=smarter_settings.platform_subdomain,
27 ), # for https://platform.example.com/
28 host(
29 rf"{SmarterEnvironments.ALPHA}.{smarter_settings.platform_subdomain}.{smarter_settings.root_domain}",
30 smarter_console_urls,
31 name=f"{SmarterEnvironments.ALPHA}_{smarter_settings.platform_subdomain}",
32 ), # for https://alpha.platform.example.com/
33 host(
34 rf"{SmarterEnvironments.BETA}.{smarter_settings.platform_subdomain}.{smarter_settings.root_domain}",
35 smarter_console_urls,
36 name=f"{SmarterEnvironments.BETA}_{smarter_settings.platform_subdomain}",
37 ), # for https://beta.platform.example.com/
38 host(
39 rf"{SmarterEnvironments.NEXT}.{smarter_settings.platform_subdomain}.{smarter_settings.root_domain}",
40 smarter_console_urls,
41 name=f"{SmarterEnvironments.NEXT}_{smarter_settings.platform_subdomain}",
42 ), # for https://next.platform.example.com/
43 # -------------------------------------------------------------------------
44 # API subdomains
45 # -------------------------------------------------------------------------
46 host(r"api.localhost:9357", smarter_api_urls, name="api_localhost"), # for http://api.localhost:9357/
47 host(r"api.127.0.0.1:9357", smarter_api_urls, name="api_127001"), # for http://api.127.0.0.1:9357/
48 host(
49 rf"{smarter_settings.api_subdomain}.{smarter_settings.root_domain}",
50 smarter_api_urls,
51 name=smarter_settings.api_subdomain,
52 ), # for https://api.platform.example.com/
53 host(
54 rf"{SmarterEnvironments.ALPHA}.{smarter_settings.api_subdomain}.{smarter_settings.root_domain}",
55 smarter_api_urls,
56 name=f"{SmarterEnvironments.ALPHA}_{smarter_settings.api_subdomain}",
57 ), # for https://alpha.api.platform.example.com/
58 host(
59 rf"{SmarterEnvironments.BETA}.{smarter_settings.api_subdomain}.{smarter_settings.root_domain}",
60 smarter_api_urls,
61 name=f"{SmarterEnvironments.BETA}_{smarter_settings.api_subdomain}",
62 ), # for https://beta.api.platform.example.com/
63 host(
64 rf"{SmarterEnvironments.NEXT}.{smarter_settings.api_subdomain}.{smarter_settings.root_domain}",
65 smarter_api_urls,
66 name=f"{SmarterEnvironments.NEXT}_{smarter_settings.api_subdomain}",
67 ), # for https://next.api.platform.example.com/
68 # -------------------------------------------------------------------------
69 # Deployed named LLMClients
70 # eg https://education.3141-5926-5359.alpha.api.example.com/
71 # -------------------------------------------------------------------------
72 host(
73 rf"(?P<llmclient_name>[\w\-]+)\.(?P<account_number>\d{{4}}-\d{{4}}-\d{{4}})\.{API_DOMAIN}",
74 smarter_llmclients_urls,
75 name="llmclient_named_api",
76 ), # for https://<llmclient_name>.<account_number>.api.platform.example.com/
77 host(
78 rf"(?P<llmclient_name>[\w\-]+)\.(?P<account_number>\d{{4}}-\d{{4}}-\d{{4}})\.{re.escape(SmarterEnvironments.ALPHA)}\.{API_DOMAIN}",
79 smarter_llmclients_urls,
80 name=f"llmclient_named_{SmarterEnvironments.ALPHA}_api",
81 ), # for https://<llmclient_name>.<account_number>.alpha.api.platform.example.com/
82 host(
83 rf"(?P<llmclient_name>[\w\-]+)\.(?P<account_number>\d{{4}}-\d{{4}}-\d{{4}})\.{re.escape(SmarterEnvironments.BETA)}\.{API_DOMAIN}",
84 smarter_llmclients_urls,
85 name=f"llmclient_named_{SmarterEnvironments.BETA}_api",
86 ), # for https://<llmclient_name>.<account_number>.beta.api.platform.example.com/
87 host(
88 rf"(?P<llmclient_name>[\w\-]+)\.(?P<account_number>\d{{4}}-\d{{4}}-\d{{4}})\.{re.escape(SmarterEnvironments.NEXT)}\.{API_DOMAIN}",
89 smarter_llmclients_urls,
90 name=f"llmclient_named_{SmarterEnvironments.NEXT}_api",
91 ), # for https://<llmclient_name>.<account_number>.next.api.platform.example.com/
92)
93
94__all__ = ["host_patterns"]