pipe.server

WSGI App for http related Pipes

App Objects

class App()

Main WSGI app wrapper which run pipes by request method

route

 | route(route: str)

Decorator for adding pipe as a handler for a route

Arguments:

  • route: Werkzeug formatted route :type route: string

wsgi_app

 | wsgi_app(environ, start_response)

Main WSGI app, see werkzeug documentation for more

run

 | run(host: str = '127.0.0.1', port: int = 8000, use_inspection: bool = False, static_folder: t.Optional[str] = None, static_url: str = '/static', *args, **kwargs)

Method for running application, actually pretty similar to the Flask run method

Arguments:

  • host: which host use for serving, defaults to '127.0.0.1' :type host: str, optional

  • port: which port to listen, defaults to 8000 :type port: int, optional

  • static_folder: points to the folder with the static files, for serving :type static_folder: str, optional

  • static_url: on what endpoint app should serve static files :type static_url: str

  • use_inspection: Toggle on inspection mode of the framework :type use_inspection: bool

pipe.server.wrappers

make_response

make_response(data, is_json: bool = False, *args, **kwargs) -> PipeResponse

Makes WSGI Response from data argument

Arguments:

  • is_json: Flag indicating whether it JSON response, or a plain one
  • data: Response data

Returns:

WSGI Response :rtype: Response

pipe.server.http

pipe.server.http.transform

TJsonResponseReady Objects

@dataclass
class TJsonResponseReady(Step)

Converts object from a 'data_field' for a simpliest API representation

pipe.server.http.exceptions

pipe.server.http.load

LJsonResponse Objects

@dataclass
class LJsonResponse(Step)

Creates JSON response from field in 'data_field' property

LResponse Objects

@dataclass
class LResponse(Step)

Sends plain response from datafield, with status from field status

pipe.server.http.extract

EFormData Objects

class EFormData(Step)

Generic extractor for form data from PipeRequest

EQueryStringData Objects

class EQueryStringData(Step)

Generic extractor for data from query string which you can find after ? sign in URL

EJsonBody Objects

class EJsonBody(Step)

Generic extractor for data which came in JSON format

pipe.server.pipe

HTTPPipe Objects

class HTTPPipe(BasePipe)

Pipe structure for the server package.

Pipe structure. Contains two parts - pipe for request and pipe for response. Data goes in next way (in): request extractor -> request transformer -> request loader (out): response extractor -> response transformer -> response loader

Example:

@app.route('/todo/')
class TodoResource(HTTPPipe):
pipe_schema = {
'GET': {
'out': (
EDatabase(table_name='todo-items'), TJsonResponseReady(data_field='todo-items_list'), LJsonResponse()
)
},
'POST': {
'in': (EJsonBody(), LDatabase(data_field='json', table_name='todo-items')),
'out': (
TLambda(lambda_=lambda store: store.copy(id=store.get('todo-items_insert'))),
EDatabase(table_name='todo-items'), TJsonResponseReady(data_field='todo-items_item'), LJsonResponse()
)
}
}

request

 | @property
 | request() -> PipeRequest

Getter for request object

run_pipe

 | run_pipe() -> frozendict

The main method. Takes data and pass through pipe. Handles request and response

:raises: PipeException