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 ChatBot Hosts
Host |
Description |
|---|---|
<chatbot_name>.<account_number>.api.example.com |
Deployed named chatbot on production API. |
<chatbot_name>.<account_number>.alpha.api.example.com |
Deployed named chatbot on alpha API. |
<chatbot_name>.<account_number>.beta.api.example.com |
Deployed named chatbot on beta API. |
<chatbot_name>.<account_number>.next.api.example.com |
Deployed named chatbot on next API. |
Each host pattern is mapped to the appropriate Django URL configuration for the console, API, or chatbot endpoints, and supports multiple environments for development, staging, and production.
1from django_hosts import host, patterns
2
3from smarter.common.conf import smarter_settings
4from smarter.common.const import SmarterEnvironments
5from smarter.urls import api as smarter_api_urls
6from smarter.urls import chatbots as smarter_chatbots_urls
7from smarter.urls import console as smarter_console_urls
8
9host_patterns = patterns(
10 "",
11 # -------------------------------------------------------------------------
12 # web console
13 # -------------------------------------------------------------------------
14 host(r"localhost:9357", smarter_console_urls, name="localhost"), # for http://localhost:9357/
15 host(r"127.0.0.1:9357", smarter_console_urls, name="127001"), # for http://127.0.0.1:9357/
16 host(
17 rf"{smarter_settings.platform_subdomain}.{smarter_settings.root_domain}",
18 smarter_console_urls,
19 name=smarter_settings.platform_subdomain,
20 ), # for https://platform.example.com/
21 host(
22 rf"{SmarterEnvironments.ALPHA}.{smarter_settings.platform_subdomain}.{smarter_settings.root_domain}",
23 smarter_console_urls,
24 name=f"{SmarterEnvironments.ALPHA}_{smarter_settings.platform_subdomain}",
25 ), # for https://alpha.platform.example.com/
26 host(
27 rf"{SmarterEnvironments.BETA}.{smarter_settings.platform_subdomain}.{smarter_settings.root_domain}",
28 smarter_console_urls,
29 name=f"{SmarterEnvironments.BETA}_{smarter_settings.platform_subdomain}",
30 ), # for https://beta.platform.example.com/
31 host(
32 rf"{SmarterEnvironments.NEXT}.{smarter_settings.platform_subdomain}.{smarter_settings.root_domain}",
33 smarter_console_urls,
34 name=f"{SmarterEnvironments.NEXT}_{smarter_settings.platform_subdomain}",
35 ), # for https://next.platform.example.com/
36 # -------------------------------------------------------------------------
37 # API subdomains
38 # -------------------------------------------------------------------------
39 host(r"api.localhost:9357", smarter_api_urls, name="api_localhost"), # for http://api.localhost:9357/
40 host(r"api.127.0.0.1:9357", smarter_api_urls, name="api_127001"), # for http://api.127.0.0.1:9357/
41 host(
42 rf"{smarter_settings.api_subdomain}.{smarter_settings.root_domain}",
43 smarter_api_urls,
44 name=smarter_settings.api_subdomain,
45 ), # for https://api.platform.example.com/
46 host(
47 rf"{SmarterEnvironments.ALPHA}.{smarter_settings.api_subdomain}.{smarter_settings.root_domain}",
48 smarter_api_urls,
49 name=f"{SmarterEnvironments.ALPHA}_{smarter_settings.api_subdomain}",
50 ), # for https://alpha.api.platform.example.com/
51 host(
52 rf"{SmarterEnvironments.BETA}.{smarter_settings.api_subdomain}.{smarter_settings.root_domain}",
53 smarter_api_urls,
54 name=f"{SmarterEnvironments.BETA}_{smarter_settings.api_subdomain}",
55 ), # for https://beta.api.platform.example.com/
56 host(
57 rf"{SmarterEnvironments.NEXT}.{smarter_settings.api_subdomain}.{smarter_settings.root_domain}",
58 smarter_api_urls,
59 name=f"{SmarterEnvironments.NEXT}_{smarter_settings.api_subdomain}",
60 ), # for https://next.api.platform.example.com/
61 # -------------------------------------------------------------------------
62 # Deployed named ChatBots
63 # eg https://education.3141-5926-5359.alpha.api.example.com/
64 # -------------------------------------------------------------------------
65 host(
66 rf"(?P<chatbot_name>[\w\-]+)\.(?P<account_number>\d{{4}}-\d{{4}})\.{smarter_settings.api_subdomain}.{smarter_settings.root_domain}",
67 smarter_chatbots_urls,
68 name="chatbot_named_api",
69 ), # for https://<chatbot_name>.<account_number>.api.platform.example.com/
70 host(
71 rf"(?P<chatbot_name>[\w\-]+)\.(?P<account_number>\d{{4}}-\d{{4}})\.{SmarterEnvironments.ALPHA}.{smarter_settings.api_subdomain}.{smarter_settings.root_domain}",
72 smarter_chatbots_urls,
73 name=f"chatbot_named_{SmarterEnvironments.ALPHA}_api",
74 ), # for https://<chatbot_name>.<account_number>.alpha.api.platform.example.com/
75 host(
76 rf"(?P<chatbot_name>[\w\-]+)\.(?P<account_number>\d{{4}}-\d{{4}})\.{SmarterEnvironments.BETA}.{smarter_settings.api_subdomain}.{smarter_settings.root_domain}",
77 smarter_chatbots_urls,
78 name=f"chatbot_named_{SmarterEnvironments.BETA}_api",
79 ), # for https://<chatbot_name>.<account_number>.beta.api.platform.example.com/
80 host(
81 rf"(?P<chatbot_name>[\w\-]+)\.(?P<account_number>\d{{4}}-\d{{4}})\.{SmarterEnvironments.NEXT}.{smarter_settings.api_subdomain}.{smarter_settings.root_domain}",
82 smarter_chatbots_urls,
83 name=f"chatbot_named_{SmarterEnvironments.NEXT}_api",
84 ), # for https://<chatbot_name>.<account_number>.next.api.platform.example.com/
85)
86
87__all__ = ["host_patterns"]