Skip to content

fastapi

numerous.frameworks.fastapi

Module for integrating Numerous with FastAPI.

FastAPICookieGetter

Source code in numerous/frameworks/fastapi.py
 9
10
11
12
13
14
15
16
17
18
19
class FastAPICookieGetter:
    def __init__(self, request: Request) -> None:
        self.request = request

    def cookies(self) -> dict[str, str]:
        """Get the cookies associated with the current request."""
        if is_local_mode():
            # Update the cookies on the fastapi server
            session.set_user_info_cookie(self.request.cookies, local_user)

        return {str(key): str(val) for key, val in self.request.cookies.items()}

cookies()

Get the cookies associated with the current request.

Source code in numerous/frameworks/fastapi.py
13
14
15
16
17
18
19
def cookies(self) -> dict[str, str]:
    """Get the cookies associated with the current request."""
    if is_local_mode():
        # Update the cookies on the fastapi server
        session.set_user_info_cookie(self.request.cookies, local_user)

    return {str(key): str(val) for key, val in self.request.cookies.items()}

get_session(request)

Get the session for the current user.

Returns:

Type Description
Session

The session for the current user.

Source code in numerous/frameworks/fastapi.py
22
23
24
25
26
27
28
29
30
def get_session(request: Request) -> Session:
    """
    Get the session for the current user.

    Returns:
        The session for the current user.

    """
    return Session(cg=FastAPICookieGetter(request))