MCPcopy Create free account
hub / github.com/apify/crawlee-python / echo_content

Function echo_content

tests/unit/server.py:394–412  ·  view source on GitHub ↗

Echo back content (plain text or base64) with specified content-type.

(scope: dict[str, Any], _receive: Receive, send: Send)

Source from the content-addressed store, hash-verified

392
393
394async def echo_content(scope: dict[str, Any], _receive: Receive, send: Send) -> None:
395 """Echo back content (plain text or base64) with specified content-type."""
396 query_params = get_query_params(scope.get('query_string', b''))
397
398 content = query_params.get('content', '')
399 base64_content = query_params.get('base64', '')
400 c_type = query_params.get('c_type', 'text/html; charset=utf-8')
401
402 out_content = base64.b64decode(base64_content) if base64_content else content.encode()
403
404 await send(
405 {
406 'type': 'http.response.start',
407 'status': 200,
408 'headers': [[b'content-type', c_type.encode()]],
409 }
410 )
411
412 await send({'type': 'http.response.body', 'body': out_content})
413
414
415async def robots_txt(_scope: dict[str, Any], _receive: Receive, send: Send) -> None:

Callers

nothing calls this directly

Calls 1

get_query_paramsFunction · 0.85

Tested by

no test coverage detected