Os.walk() doesn't work inside a page


I am trying to list the content of a folder using os.walk(). The function is in a page (inside the pages folder) and looks as follows:

def list_files(directory):
    file_list = []
    for  root, dirs, files in os.walk(directory, topdown=False):
        for name in files:
    return file_list

The result of this is blankspace. This should not be the case as there are files inside the folder.
directory is the full file path

Hi, not sure what you are referring to with this, but try moving your function into a utils.py at app- level (outside the pages folder).

This is the only suggestion I have considering the information you provided. Maybe you could provide more code/ information of your set up.