moderate-tomatoM
Apify & Crawlee13mo ago
4 replies
moderate-tomato

how to pass data to routes.py

If i use multiple files, what is the best way to pass data (user input, which contains 'max_results' or something) to my routes.py?

example snippet main.py
        max_results = 5 # example

        crawler = PlaywrightCrawler(
            headless=False, 
            request_handler=router,
        )
        await crawler.run([start_url])


snippet routes.py
@router.default_handler
async def default_handler(context: PlaywrightCrawlingContext) -> None:
    max_results = ???
Was this page helpful?