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

Function app

tests/unit/server.py:95–142  ·  view source on GitHub ↗

Main ASGI application handler that routes requests to specific handlers. Args: scope: The ASGI connection scope. receive: The ASGI receive function. send: The ASGI send function.

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

Source from the content-addressed store, hash-verified

93
94
95async def app(scope: dict[str, Any], receive: Receive, send: Send) -> None:
96 """Main ASGI application handler that routes requests to specific handlers.
97
98 Args:
99 scope: The ASGI connection scope.
100 receive: The ASGI receive function.
101 send: The ASGI send function.
102 """
103 assert scope['type'] == 'http'
104 paths: dict[str, PathHandler] = {
105 'start_enqueue': start_enqueue_endpoint,
106 'start_enqueue_non_href': start_enqueue_non_href_endpoint,
107 'sub_index': secondary_index_endpoint,
108 'incapsula': incapsula_endpoint,
109 'page_1': generic_response_endpoint,
110 'page_2': generic_response_endpoint,
111 'page_3': generic_response_endpoint,
112 'base_page': base_index_endpoint,
113 'problematic_links': problematic_links_endpoint,
114 'non_href_links': non_href_links_endpoint,
115 'set_cookies': set_cookies,
116 'set_complex_cookies': set_complex_cookies,
117 'cookies': get_cookies,
118 'status': echo_status,
119 'headers': echo_headers,
120 'user-agent': echo_user_agent,
121 'echo_content': echo_content,
122 'sitemap.txt': echo_content,
123 'sitemap.xml': echo_content,
124 'sitemap.xml.gz': echo_content,
125 'get': get_echo,
126 'post': post_echo,
127 'redirect': redirect_to_url,
128 'json': hello_world_json,
129 'xml': hello_world_xml,
130 'robots.txt': robots_txt,
131 'get_compressed': get_compressed,
132 'slow': slow_response,
133 'infinite_scroll': infinite_scroll_endpoint,
134 'resource_loading_page': resource_loading_endpoint,
135 }
136 path = URL(scope['path']).parts[1]
137 # Route requests to appropriate handlers
138 if path in paths:
139 path_func = paths[path]
140 await path_func(scope, receive, send)
141 else:
142 await hello_world(scope, receive, send)
143
144
145async def get_cookies(scope: dict[str, Any], _receive: Receive, send: Send) -> None:

Callers

nothing calls this directly

Calls 1

hello_worldFunction · 0.85

Tested by

no test coverage detected