MCPcopy
hub / github.com/tornadoweb/tornado / __init__

Method __init__

tornado/web.py:2212–2266  ·  view source on GitHub ↗
(
        self,
        handlers: Optional[_RuleList] = None,
        default_host: Optional[str] = None,
        transforms: Optional[List[Type["OutputTransform"]]] = None,
        **settings: Any,
    )

Source from the content-addressed store, hash-verified

2210 """
2211
2212 def __init__(
2213 self,
2214 handlers: Optional[_RuleList] = None,
2215 default_host: Optional[str] = None,
2216 transforms: Optional[List[Type["OutputTransform"]]] = None,
2217 **settings: Any,
2218 ) -> None:
2219 if transforms is None:
2220 self.transforms = [] # type: List[Type[OutputTransform]]
2221 if settings.get("compress_response") or settings.get("gzip"):
2222 self.transforms.append(GZipContentEncoding)
2223 else:
2224 self.transforms = transforms
2225 self.default_host = default_host
2226 self.settings = settings
2227 self.ui_modules = {
2228 "linkify": _linkify,
2229 "xsrf_form_html": _xsrf_form_html,
2230 "Template": TemplateModule,
2231 }
2232 self.ui_methods = {} # type: Dict[str, Callable[..., str]]
2233 self._load_ui_modules(settings.get("ui_modules", {}))
2234 self._load_ui_methods(settings.get("ui_methods", {}))
2235 if self.settings.get("static_path"):
2236 path = self.settings["static_path"]
2237 handlers = list(handlers or [])
2238 static_url_prefix = settings.get("static_url_prefix", "/static/")
2239 static_handler_class = settings.get(
2240 "static_handler_class", StaticFileHandler
2241 )
2242 static_handler_args = settings.get("static_handler_args", {})
2243 static_handler_args["path"] = path
2244 for pattern in [
2245 re.escape(static_url_prefix) + r"(.*)",
2246 r"/(favicon\.ico)",
2247 r"/(robots\.txt)",
2248 ]:
2249 handlers.insert(0, (pattern, static_handler_class, static_handler_args))
2250
2251 if self.settings.get("debug"):
2252 self.settings.setdefault("autoreload", True)
2253 self.settings.setdefault("compiled_template_cache", False)
2254 self.settings.setdefault("static_hash_cache", False)
2255 self.settings.setdefault("serve_traceback", True)
2256
2257 self.wildcard_router = _ApplicationRouter(self, handlers)
2258 self.default_router = _ApplicationRouter(
2259 self, [Rule(AnyMatches(), self.wildcard_router)]
2260 )
2261
2262 # Automatically reload modified modules
2263 if self.settings.get("autoreload"):
2264 from tornado import autoreload
2265
2266 autoreload.start()
2267
2268 def listen(
2269 self,

Callers

nothing calls this directly

Calls 8

_load_ui_modulesMethod · 0.95
_load_ui_methodsMethod · 0.95
RuleClass · 0.90
AnyMatchesClass · 0.90
_ApplicationRouterClass · 0.85
appendMethod · 0.80
getMethod · 0.45
startMethod · 0.45

Tested by

no test coverage detected