_internal.py 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626
  1. import inspect
  2. import logging
  3. import operator
  4. import re
  5. import string
  6. import sys
  7. import typing
  8. import typing as t
  9. from datetime import date
  10. from datetime import datetime
  11. from datetime import timezone
  12. from itertools import chain
  13. from weakref import WeakKeyDictionary
  14. if t.TYPE_CHECKING:
  15. from _typeshed.wsgi import StartResponse
  16. from _typeshed.wsgi import WSGIApplication
  17. from _typeshed.wsgi import WSGIEnvironment
  18. from .wrappers.request import Request # noqa: F401
  19. _logger: t.Optional[logging.Logger] = None
  20. _signature_cache = WeakKeyDictionary() # type: ignore
  21. _epoch_ord = date(1970, 1, 1).toordinal()
  22. _legal_cookie_chars = frozenset(
  23. c.encode("ascii")
  24. for c in f"{string.ascii_letters}{string.digits}/=!#$%&'*+-.^_`|~:"
  25. )
  26. _cookie_quoting_map = {b",": b"\\054", b";": b"\\073", b'"': b'\\"', b"\\": b"\\\\"}
  27. for _i in chain(range(32), range(127, 256)):
  28. _cookie_quoting_map[_i.to_bytes(1, sys.byteorder)] = f"\\{_i:03o}".encode("latin1")
  29. _octal_re = re.compile(rb"\\[0-3][0-7][0-7]")
  30. _quote_re = re.compile(rb"[\\].")
  31. _legal_cookie_chars_re = rb"[\w\d!#%&\'~_`><@,:/\$\*\+\-\.\^\|\)\(\?\}\{\=]"
  32. _cookie_re = re.compile(
  33. rb"""
  34. (?P<key>[^=;]+)
  35. (?:\s*=\s*
  36. (?P<val>
  37. "(?:[^\\"]|\\.)*" |
  38. (?:.*?)
  39. )
  40. )?
  41. \s*;
  42. """,
  43. flags=re.VERBOSE,
  44. )
  45. class _Missing:
  46. def __repr__(self) -> str:
  47. return "no value"
  48. def __reduce__(self) -> str:
  49. return "_missing"
  50. _missing = _Missing()
  51. @typing.overload
  52. def _make_encode_wrapper(reference: str) -> t.Callable[[str], str]:
  53. ...
  54. @typing.overload
  55. def _make_encode_wrapper(reference: bytes) -> t.Callable[[str], bytes]:
  56. ...
  57. def _make_encode_wrapper(reference: t.AnyStr) -> t.Callable[[str], t.AnyStr]:
  58. """Create a function that will be called with a string argument. If
  59. the reference is bytes, values will be encoded to bytes.
  60. """
  61. if isinstance(reference, str):
  62. return lambda x: x
  63. return operator.methodcaller("encode", "latin1")
  64. def _check_str_tuple(value: t.Tuple[t.AnyStr, ...]) -> None:
  65. """Ensure tuple items are all strings or all bytes."""
  66. if not value:
  67. return
  68. item_type = str if isinstance(value[0], str) else bytes
  69. if any(not isinstance(item, item_type) for item in value):
  70. raise TypeError(f"Cannot mix str and bytes arguments (got {value!r})")
  71. _default_encoding = sys.getdefaultencoding()
  72. def _to_bytes(
  73. x: t.Union[str, bytes], charset: str = _default_encoding, errors: str = "strict"
  74. ) -> bytes:
  75. if x is None or isinstance(x, bytes):
  76. return x
  77. if isinstance(x, (bytearray, memoryview)):
  78. return bytes(x)
  79. if isinstance(x, str):
  80. return x.encode(charset, errors)
  81. raise TypeError("Expected bytes")
  82. @typing.overload
  83. def _to_str( # type: ignore
  84. x: None,
  85. charset: t.Optional[str] = ...,
  86. errors: str = ...,
  87. allow_none_charset: bool = ...,
  88. ) -> None:
  89. ...
  90. @typing.overload
  91. def _to_str(
  92. x: t.Any,
  93. charset: t.Optional[str] = ...,
  94. errors: str = ...,
  95. allow_none_charset: bool = ...,
  96. ) -> str:
  97. ...
  98. def _to_str(
  99. x: t.Optional[t.Any],
  100. charset: t.Optional[str] = _default_encoding,
  101. errors: str = "strict",
  102. allow_none_charset: bool = False,
  103. ) -> t.Optional[t.Union[str, bytes]]:
  104. if x is None or isinstance(x, str):
  105. return x
  106. if not isinstance(x, (bytes, bytearray)):
  107. return str(x)
  108. if charset is None:
  109. if allow_none_charset:
  110. return x
  111. return x.decode(charset, errors) # type: ignore
  112. def _wsgi_decoding_dance(
  113. s: str, charset: str = "utf-8", errors: str = "replace"
  114. ) -> str:
  115. return s.encode("latin1").decode(charset, errors)
  116. def _wsgi_encoding_dance(
  117. s: str, charset: str = "utf-8", errors: str = "replace"
  118. ) -> str:
  119. if isinstance(s, bytes):
  120. return s.decode("latin1", errors)
  121. return s.encode(charset).decode("latin1", errors)
  122. def _get_environ(obj: t.Union["WSGIEnvironment", "Request"]) -> "WSGIEnvironment":
  123. env = getattr(obj, "environ", obj)
  124. assert isinstance(
  125. env, dict
  126. ), f"{type(obj).__name__!r} is not a WSGI environment (has to be a dict)"
  127. return env
  128. def _has_level_handler(logger: logging.Logger) -> bool:
  129. """Check if there is a handler in the logging chain that will handle
  130. the given logger's effective level.
  131. """
  132. level = logger.getEffectiveLevel()
  133. current = logger
  134. while current:
  135. if any(handler.level <= level for handler in current.handlers):
  136. return True
  137. if not current.propagate:
  138. break
  139. current = current.parent # type: ignore
  140. return False
  141. class _ColorStreamHandler(logging.StreamHandler):
  142. """On Windows, wrap stream with Colorama for ANSI style support."""
  143. def __init__(self) -> None:
  144. try:
  145. import colorama
  146. except ImportError:
  147. stream = None
  148. else:
  149. stream = colorama.AnsiToWin32(sys.stderr)
  150. super().__init__(stream)
  151. def _log(type: str, message: str, *args: t.Any, **kwargs: t.Any) -> None:
  152. """Log a message to the 'werkzeug' logger.
  153. The logger is created the first time it is needed. If there is no
  154. level set, it is set to :data:`logging.INFO`. If there is no handler
  155. for the logger's effective level, a :class:`logging.StreamHandler`
  156. is added.
  157. """
  158. global _logger
  159. if _logger is None:
  160. _logger = logging.getLogger("werkzeug")
  161. if _logger.level == logging.NOTSET:
  162. _logger.setLevel(logging.INFO)
  163. if not _has_level_handler(_logger):
  164. _logger.addHandler(_ColorStreamHandler())
  165. getattr(_logger, type)(message.rstrip(), *args, **kwargs)
  166. def _parse_signature(func): # type: ignore
  167. """Return a signature object for the function.
  168. .. deprecated:: 2.0
  169. Will be removed in Werkzeug 2.1 along with ``utils.bind`` and
  170. ``validate_arguments``.
  171. """
  172. # if we have a cached validator for this function, return it
  173. parse = _signature_cache.get(func)
  174. if parse is not None:
  175. return parse
  176. # inspect the function signature and collect all the information
  177. tup = inspect.getfullargspec(func)
  178. positional, vararg_var, kwarg_var, defaults = tup[:4]
  179. defaults = defaults or ()
  180. arg_count = len(positional)
  181. arguments = []
  182. for idx, name in enumerate(positional):
  183. if isinstance(name, list):
  184. raise TypeError(
  185. "cannot parse functions that unpack tuples in the function signature"
  186. )
  187. try:
  188. default = defaults[idx - arg_count]
  189. except IndexError:
  190. param = (name, False, None)
  191. else:
  192. param = (name, True, default)
  193. arguments.append(param)
  194. arguments = tuple(arguments)
  195. def parse(args, kwargs): # type: ignore
  196. new_args = []
  197. missing = []
  198. extra = {}
  199. # consume as many arguments as positional as possible
  200. for idx, (name, has_default, default) in enumerate(arguments):
  201. try:
  202. new_args.append(args[idx])
  203. except IndexError:
  204. try:
  205. new_args.append(kwargs.pop(name))
  206. except KeyError:
  207. if has_default:
  208. new_args.append(default)
  209. else:
  210. missing.append(name)
  211. else:
  212. if name in kwargs:
  213. extra[name] = kwargs.pop(name)
  214. # handle extra arguments
  215. extra_positional = args[arg_count:]
  216. if vararg_var is not None:
  217. new_args.extend(extra_positional)
  218. extra_positional = ()
  219. if kwargs and kwarg_var is None:
  220. extra.update(kwargs)
  221. kwargs = {}
  222. return (
  223. new_args,
  224. kwargs,
  225. missing,
  226. extra,
  227. extra_positional,
  228. arguments,
  229. vararg_var,
  230. kwarg_var,
  231. )
  232. _signature_cache[func] = parse
  233. return parse
  234. @typing.overload
  235. def _dt_as_utc(dt: None) -> None:
  236. ...
  237. @typing.overload
  238. def _dt_as_utc(dt: datetime) -> datetime:
  239. ...
  240. def _dt_as_utc(dt: t.Optional[datetime]) -> t.Optional[datetime]:
  241. if dt is None:
  242. return dt
  243. if dt.tzinfo is None:
  244. return dt.replace(tzinfo=timezone.utc)
  245. elif dt.tzinfo != timezone.utc:
  246. return dt.astimezone(timezone.utc)
  247. return dt
  248. _TAccessorValue = t.TypeVar("_TAccessorValue")
  249. class _DictAccessorProperty(t.Generic[_TAccessorValue]):
  250. """Baseclass for `environ_property` and `header_property`."""
  251. read_only = False
  252. def __init__(
  253. self,
  254. name: str,
  255. default: t.Optional[_TAccessorValue] = None,
  256. load_func: t.Optional[t.Callable[[str], _TAccessorValue]] = None,
  257. dump_func: t.Optional[t.Callable[[_TAccessorValue], str]] = None,
  258. read_only: t.Optional[bool] = None,
  259. doc: t.Optional[str] = None,
  260. ) -> None:
  261. self.name = name
  262. self.default = default
  263. self.load_func = load_func
  264. self.dump_func = dump_func
  265. if read_only is not None:
  266. self.read_only = read_only
  267. self.__doc__ = doc
  268. def lookup(self, instance: t.Any) -> t.MutableMapping[str, t.Any]:
  269. raise NotImplementedError
  270. @typing.overload
  271. def __get__(
  272. self, instance: None, owner: type
  273. ) -> "_DictAccessorProperty[_TAccessorValue]":
  274. ...
  275. @typing.overload
  276. def __get__(self, instance: t.Any, owner: type) -> _TAccessorValue:
  277. ...
  278. def __get__(
  279. self, instance: t.Optional[t.Any], owner: type
  280. ) -> t.Union[_TAccessorValue, "_DictAccessorProperty[_TAccessorValue]"]:
  281. if instance is None:
  282. return self
  283. storage = self.lookup(instance)
  284. if self.name not in storage:
  285. return self.default # type: ignore
  286. value = storage[self.name]
  287. if self.load_func is not None:
  288. try:
  289. return self.load_func(value)
  290. except (ValueError, TypeError):
  291. return self.default # type: ignore
  292. return value # type: ignore
  293. def __set__(self, instance: t.Any, value: _TAccessorValue) -> None:
  294. if self.read_only:
  295. raise AttributeError("read only property")
  296. if self.dump_func is not None:
  297. self.lookup(instance)[self.name] = self.dump_func(value)
  298. else:
  299. self.lookup(instance)[self.name] = value
  300. def __delete__(self, instance: t.Any) -> None:
  301. if self.read_only:
  302. raise AttributeError("read only property")
  303. self.lookup(instance).pop(self.name, None)
  304. def __repr__(self) -> str:
  305. return f"<{type(self).__name__} {self.name}>"
  306. def _cookie_quote(b: bytes) -> bytes:
  307. buf = bytearray()
  308. all_legal = True
  309. _lookup = _cookie_quoting_map.get
  310. _push = buf.extend
  311. for char_int in b:
  312. char = char_int.to_bytes(1, sys.byteorder)
  313. if char not in _legal_cookie_chars:
  314. all_legal = False
  315. char = _lookup(char, char)
  316. _push(char)
  317. if all_legal:
  318. return bytes(buf)
  319. return bytes(b'"' + buf + b'"')
  320. def _cookie_unquote(b: bytes) -> bytes:
  321. if len(b) < 2:
  322. return b
  323. if b[:1] != b'"' or b[-1:] != b'"':
  324. return b
  325. b = b[1:-1]
  326. i = 0
  327. n = len(b)
  328. rv = bytearray()
  329. _push = rv.extend
  330. while 0 <= i < n:
  331. o_match = _octal_re.search(b, i)
  332. q_match = _quote_re.search(b, i)
  333. if not o_match and not q_match:
  334. rv.extend(b[i:])
  335. break
  336. j = k = -1
  337. if o_match:
  338. j = o_match.start(0)
  339. if q_match:
  340. k = q_match.start(0)
  341. if q_match and (not o_match or k < j):
  342. _push(b[i:k])
  343. _push(b[k + 1 : k + 2])
  344. i = k + 2
  345. else:
  346. _push(b[i:j])
  347. rv.append(int(b[j + 1 : j + 4], 8))
  348. i = j + 4
  349. return bytes(rv)
  350. def _cookie_parse_impl(b: bytes) -> t.Iterator[t.Tuple[bytes, bytes]]:
  351. """Lowlevel cookie parsing facility that operates on bytes."""
  352. i = 0
  353. n = len(b)
  354. while i < n:
  355. match = _cookie_re.search(b + b";", i)
  356. if not match:
  357. break
  358. key = match.group("key").strip()
  359. value = match.group("val") or b""
  360. i = match.end(0)
  361. yield key, _cookie_unquote(value)
  362. def _encode_idna(domain: str) -> bytes:
  363. # If we're given bytes, make sure they fit into ASCII
  364. if isinstance(domain, bytes):
  365. domain.decode("ascii")
  366. return domain
  367. # Otherwise check if it's already ascii, then return
  368. try:
  369. return domain.encode("ascii")
  370. except UnicodeError:
  371. pass
  372. # Otherwise encode each part separately
  373. return b".".join(p.encode("idna") for p in domain.split("."))
  374. def _decode_idna(domain: t.Union[str, bytes]) -> str:
  375. # If the input is a string try to encode it to ascii to do the idna
  376. # decoding. If that fails because of a unicode error, then we
  377. # already have a decoded idna domain.
  378. if isinstance(domain, str):
  379. try:
  380. domain = domain.encode("ascii")
  381. except UnicodeError:
  382. return domain # type: ignore
  383. # Decode each part separately. If a part fails, try to decode it
  384. # with ascii and silently ignore errors. This makes sense because
  385. # the idna codec does not have error handling.
  386. def decode_part(part: bytes) -> str:
  387. try:
  388. return part.decode("idna")
  389. except UnicodeError:
  390. return part.decode("ascii", "ignore")
  391. return ".".join(decode_part(p) for p in domain.split(b"."))
  392. @typing.overload
  393. def _make_cookie_domain(domain: None) -> None:
  394. ...
  395. @typing.overload
  396. def _make_cookie_domain(domain: str) -> bytes:
  397. ...
  398. def _make_cookie_domain(domain: t.Optional[str]) -> t.Optional[bytes]:
  399. if domain is None:
  400. return None
  401. domain = _encode_idna(domain)
  402. if b":" in domain:
  403. domain = domain.split(b":", 1)[0]
  404. if b"." in domain:
  405. return domain
  406. raise ValueError(
  407. "Setting 'domain' for a cookie on a server running locally (ex: "
  408. "localhost) is not supported by complying browsers. You should "
  409. "have something like: '127.0.0.1 localhost dev.localhost' on "
  410. "your hosts file and then point your server to run on "
  411. "'dev.localhost' and also set 'domain' for 'dev.localhost'"
  412. )
  413. def _easteregg(app: t.Optional["WSGIApplication"] = None) -> "WSGIApplication":
  414. """Like the name says. But who knows how it works?"""
  415. def bzzzzzzz(gyver: bytes) -> str:
  416. import base64
  417. import zlib
  418. return zlib.decompress(base64.b64decode(gyver)).decode("ascii")
  419. gyver = "\n".join(
  420. [
  421. x + (77 - len(x)) * " "
  422. for x in bzzzzzzz(
  423. b"""
  424. eJyFlzuOJDkMRP06xRjymKgDJCDQStBYT8BCgK4gTwfQ2fcFs2a2FzvZk+hvlcRvRJD148efHt9m
  425. 9Xz94dRY5hGt1nrYcXx7us9qlcP9HHNh28rz8dZj+q4rynVFFPdlY4zH873NKCexrDM6zxxRymzz
  426. 4QIxzK4bth1PV7+uHn6WXZ5C4ka/+prFzx3zWLMHAVZb8RRUxtFXI5DTQ2n3Hi2sNI+HK43AOWSY
  427. jmEzE4naFp58PdzhPMdslLVWHTGUVpSxImw+pS/D+JhzLfdS1j7PzUMxij+mc2U0I9zcbZ/HcZxc
  428. q1QjvvcThMYFnp93agEx392ZdLJWXbi/Ca4Oivl4h/Y1ErEqP+lrg7Xa4qnUKu5UE9UUA4xeqLJ5
  429. jWlPKJvR2yhRI7xFPdzPuc6adXu6ovwXwRPXXnZHxlPtkSkqWHilsOrGrvcVWXgGP3daXomCj317
  430. 8P2UOw/NnA0OOikZyFf3zZ76eN9QXNwYdD8f8/LdBRFg0BO3bB+Pe/+G8er8tDJv83XTkj7WeMBJ
  431. v/rnAfdO51d6sFglfi8U7zbnr0u9tyJHhFZNXYfH8Iafv2Oa+DT6l8u9UYlajV/hcEgk1x8E8L/r
  432. XJXl2SK+GJCxtnyhVKv6GFCEB1OO3f9YWAIEbwcRWv/6RPpsEzOkXURMN37J0PoCSYeBnJQd9Giu
  433. LxYQJNlYPSo/iTQwgaihbART7Fcyem2tTSCcwNCs85MOOpJtXhXDe0E7zgZJkcxWTar/zEjdIVCk
  434. iXy87FW6j5aGZhttDBoAZ3vnmlkx4q4mMmCdLtnHkBXFMCReqthSGkQ+MDXLLCpXwBs0t+sIhsDI
  435. tjBB8MwqYQpLygZ56rRHHpw+OAVyGgaGRHWy2QfXez+ZQQTTBkmRXdV/A9LwH6XGZpEAZU8rs4pE
  436. 1R4FQ3Uwt8RKEtRc0/CrANUoes3EzM6WYcFyskGZ6UTHJWenBDS7h163Eo2bpzqxNE9aVgEM2CqI
  437. GAJe9Yra4P5qKmta27VjzYdR04Vc7KHeY4vs61C0nbywFmcSXYjzBHdiEjraS7PGG2jHHTpJUMxN
  438. Jlxr3pUuFvlBWLJGE3GcA1/1xxLcHmlO+LAXbhrXah1tD6Ze+uqFGdZa5FM+3eHcKNaEarutAQ0A
  439. QMAZHV+ve6LxAwWnXbbSXEG2DmCX5ijeLCKj5lhVFBrMm+ryOttCAeFpUdZyQLAQkA06RLs56rzG
  440. 8MID55vqr/g64Qr/wqwlE0TVxgoiZhHrbY2h1iuuyUVg1nlkpDrQ7Vm1xIkI5XRKLedN9EjzVchu
  441. jQhXcVkjVdgP2O99QShpdvXWoSwkp5uMwyjt3jiWCqWGSiaaPAzohjPanXVLbM3x0dNskJsaCEyz
  442. DTKIs+7WKJD4ZcJGfMhLFBf6hlbnNkLEePF8Cx2o2kwmYF4+MzAxa6i+6xIQkswOqGO+3x9NaZX8
  443. MrZRaFZpLeVTYI9F/djY6DDVVs340nZGmwrDqTCiiqD5luj3OzwpmQCiQhdRYowUYEA3i1WWGwL4
  444. GCtSoO4XbIPFeKGU13XPkDf5IdimLpAvi2kVDVQbzOOa4KAXMFlpi/hV8F6IDe0Y2reg3PuNKT3i
  445. RYhZqtkQZqSB2Qm0SGtjAw7RDwaM1roESC8HWiPxkoOy0lLTRFG39kvbLZbU9gFKFRvixDZBJmpi
  446. Xyq3RE5lW00EJjaqwp/v3EByMSpVZYsEIJ4APaHmVtpGSieV5CALOtNUAzTBiw81GLgC0quyzf6c
  447. NlWknzJeCsJ5fup2R4d8CYGN77mu5vnO1UqbfElZ9E6cR6zbHjgsr9ly18fXjZoPeDjPuzlWbFwS
  448. pdvPkhntFvkc13qb9094LL5NrA3NIq3r9eNnop9DizWOqCEbyRBFJTHn6Tt3CG1o8a4HevYh0XiJ
  449. sR0AVVHuGuMOIfbuQ/OKBkGRC6NJ4u7sbPX8bG/n5sNIOQ6/Y/BX3IwRlTSabtZpYLB85lYtkkgm
  450. p1qXK3Du2mnr5INXmT/78KI12n11EFBkJHHp0wJyLe9MvPNUGYsf+170maayRoy2lURGHAIapSpQ
  451. krEDuNoJCHNlZYhKpvw4mspVWxqo415n8cD62N9+EfHrAvqQnINStetek7RY2Urv8nxsnGaZfRr/
  452. nhXbJ6m/yl1LzYqscDZA9QHLNbdaSTTr+kFg3bC0iYbX/eQy0Bv3h4B50/SGYzKAXkCeOLI3bcAt
  453. mj2Z/FM1vQWgDynsRwNvrWnJHlespkrp8+vO1jNaibm+PhqXPPv30YwDZ6jApe3wUjFQobghvW9p
  454. 7f2zLkGNv8b191cD/3vs9Q833z8t"""
  455. ).splitlines()
  456. ]
  457. )
  458. def easteregged(
  459. environ: "WSGIEnvironment", start_response: "StartResponse"
  460. ) -> t.Iterable[bytes]:
  461. def injecting_start_response(
  462. status: str, headers: t.List[t.Tuple[str, str]], exc_info: t.Any = None
  463. ) -> t.Callable[[bytes], t.Any]:
  464. headers.append(("X-Powered-By", "Werkzeug"))
  465. return start_response(status, headers, exc_info)
  466. if app is not None and environ.get("QUERY_STRING") != "macgybarchakku":
  467. return app(environ, injecting_start_response)
  468. injecting_start_response("200 OK", [("Content-Type", "text/html")])
  469. return [
  470. f"""\
  471. <!DOCTYPE html>
  472. <html>
  473. <head>
  474. <title>About Werkzeug</title>
  475. <style type="text/css">
  476. body {{ font: 15px Georgia, serif; text-align: center; }}
  477. a {{ color: #333; text-decoration: none; }}
  478. h1 {{ font-size: 30px; margin: 20px 0 10px 0; }}
  479. p {{ margin: 0 0 30px 0; }}
  480. pre {{ font: 11px 'Consolas', 'Monaco', monospace; line-height: 0.95; }}
  481. </style>
  482. </head>
  483. <body>
  484. <h1><a href="http://werkzeug.pocoo.org/">Werkzeug</a></h1>
  485. <p>the Swiss Army knife of Python web development.</p>
  486. <pre>{gyver}\n\n\n</pre>
  487. </body>
  488. </html>""".encode(
  489. "latin1"
  490. )
  491. ]
  492. return easteregged