How to use the klein.Field function in klein

To help you get started, we’ve selected a few klein examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github twisted / klein / loginspike.py View on Github external
    value=Field.text(),
    chirper=Authorization(Chirper),
)
@inlineCallbacks
def addChirp(chirper, value):
    # type: (Chirper, str) -> Deferred
    yield chirper.chirp(value)
    returnValue(Redirect(b"/"))
github twisted / klein / loginspike.py View on Github external
    sessionID=Field.text(),
    url=RequestURL(),
)
@inlineCallbacks
def logOtherOut(sessionID, binding, url):
    # type: (str, ISimpleAccountBinding, DecodedURL) -> Deferred
    from attr import assoc
    # TODO: public API for getting to this?
    session = yield binding._session._sessionStore.loadSession(
        sessionID, url.scheme == u'https', SessionMechanism.Header
    )
    other_binding = assoc(binding, _session=session)
    yield other_binding.unbindThisSession()
    returnValue(Redirect(b"/sessions"))