|
35 | 35 | EngagePages, |
36 | 36 | TutorialParser, |
37 | 37 | Tutorials, |
| 38 | + ResponseCache, |
38 | 39 | ) |
39 | 40 | from canonicalwebteam.flask_base.app import FlaskBase |
40 | 41 | from canonicalwebteam.flask_base.env import get_flask_env |
|
121 | 122 | # Serves any page as Markdown via ?format=md query parameter |
122 | 123 | MarkdownResponse(app) |
123 | 124 |
|
124 | | -# Load env variables after the app is initialized |
125 | | -CHARMHUB_DISCOURSE_API_KEY = os.getenv("CHARMHUB_DISCOURSE_API_KEY") |
126 | | -CHARMHUB_DISCOURSE_API_USERNAME = os.getenv("CHARMHUB_DISCOURSE_API_USERNAME") |
127 | | - |
128 | 125 | RECAPTCHA_CONFIG = load_recaptcha_config() |
129 | 126 | RECAPTCHA_SITE_KEY = RECAPTCHA_CONFIG.get("site_key") |
130 | 127 | if not RECAPTCHA_SITE_KEY: |
|
146 | 143 |
|
147 | 144 | # Loader supplied to jinja_loader overwrites default jinja_loader |
148 | 145 | app.jinja_loader = loader |
149 | | - |
150 | | -charmhub_discourse_api = DiscourseAPI( |
151 | | - base_url="https://discourse.charmhub.io/", |
152 | | - session=get_requests_session(), |
153 | | - api_key=CHARMHUB_DISCOURSE_API_KEY, |
154 | | - api_username=CHARMHUB_DISCOURSE_API_USERNAME, |
155 | | - get_topics_query_id=2, |
156 | | -) |
157 | 146 | search_session = get_requests_session() |
158 | 147 | discourse_session = get_requests_session() |
159 | 148 |
|
@@ -1144,6 +1133,7 @@ def allow_src(tag, name, value): |
1144 | 1133 | api=DiscourseAPI( |
1145 | 1134 | base_url="https://discourse.dqlite.io/", |
1146 | 1135 | session=discourse_session, |
| 1136 | + cache=ResponseCache(ttl=600), |
1147 | 1137 | ), |
1148 | 1138 | index_topic_id=34, |
1149 | 1139 | url_prefix="/dqlite/docs", |
@@ -1177,6 +1167,7 @@ def allow_src(tag, name, value): |
1177 | 1167 | base_url="https://discourse.maas.io/", |
1178 | 1168 | session=discourse_session, |
1179 | 1169 | get_topics_query_id=2, |
| 1170 | + cache=ResponseCache(ttl=600), |
1180 | 1171 | ), |
1181 | 1172 | index_topic_id=6662, |
1182 | 1173 | url_prefix=maas_url_prefix, |
@@ -1261,6 +1252,7 @@ def maas_docs_api(): |
1261 | 1252 | api_key=MAAS_DISCOURSE_API_KEY, |
1262 | 1253 | api_username=MAAS_DISCOURSE_API_USERNAME, |
1263 | 1254 | get_topics_query_id=2, |
| 1255 | + cache=ResponseCache(ttl=600), |
1264 | 1256 | ), |
1265 | 1257 | index_topic_id=1289, |
1266 | 1258 | url_prefix="/maas/tutorials", |
@@ -1524,6 +1516,7 @@ def cred_exam_content(**_): |
1524 | 1516 | get_topics_query_id=14, |
1525 | 1517 | api_key=DISCOURSE_API_KEY, |
1526 | 1518 | api_username=DISCOURSE_API_USERNAME, |
| 1519 | + cache=ResponseCache(ttl=600), |
1527 | 1520 | ) |
1528 | 1521 | engage_pages = EngagePages( |
1529 | 1522 | api=engage_pages_discourse_api, |
@@ -1553,6 +1546,7 @@ def cred_exam_content(**_): |
1553 | 1546 | session=search_session, |
1554 | 1547 | api_key=DISCOURSE_API_KEY, |
1555 | 1548 | api_username=DISCOURSE_API_USERNAME, |
| 1549 | + cache=ResponseCache(ttl=600), |
1556 | 1550 | ) |
1557 | 1551 |
|
1558 | 1552 |
|
@@ -1588,6 +1582,7 @@ def cred_exam_content(**_): |
1588 | 1582 | api=DiscourseAPI( |
1589 | 1583 | base_url="https://discuss.kubernetes.io/", |
1590 | 1584 | session=get_requests_session(), |
| 1585 | + cache=ResponseCache(ttl=600), |
1591 | 1586 | ), |
1592 | 1587 | index_topic_id=11243, |
1593 | 1588 | url_prefix=microk8s_url_prefix, |
|
0 commit comments