Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
from ._interfaces import IHTTPHeaders, IHTTPRequest
from ._message import MessageState, bodyAsBytes, bodyAsFount, validateBody
__all__ = ()
@implementer(IHTTPRequest) # type: ignore[misc]
@attrs(frozen=True)
class FrozenHTTPRequest(object):
"""
Immutable HTTP request.
"""
method = attrib(validator=instance_of(Text)) # type: Text
uri = attrib(validator=instance_of(DecodedURL)) # type: DecodedURL
headers = attrib(
validator=provides(IHTTPHeaders) # type: ignore[misc]
) # type: IHTTPHeaders
_body = attrib(validator=validateBody) # type: Union[bytes, IFount]
_state = attrib(
default=Factory(MessageState), init=False
) # type: MessageState
def bodyAsFount(self):
# type: () -> IFount
return bodyAsFount(self._body, self._state)
def bodyAsBytes(self):
# type: () -> Deferred[bytes]
from klein.interfaces import (
ISimpleAccountBinding, SessionMechanism, ISimpleAccount, ISessionProcurer,
ISessionStore, ISession
)
from klein.storage.sql import (
procurerFromDataStore, authorizerFor, SessionSchema, DataStore, Transaction
)
from twisted.web.util import Redirect
if TYPE_CHECKING:
from hyperlink import DecodedURL
# silence flake8 for type-checking
(ISessionProcurer, Deferred, IRequest, Dict, Tag, Any, RenderableForm,
ISessionStore, DecodedURL)
app = Klein()
def bootstrap(x):
# type: (str) -> str
return "https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/" + x
requirer = Requirer()
style = Plating(
tags=tags.html(
tags.head(
tags.link(rel="stylesheet",
href=bootstrap("css/bootstrap.min.css"),
crossorigin="anonymous"),
# tags.script(