MCPcopy Create free account
hub / github.com/pywebio/PyWebIO / default_index_page

Function default_index_page

pywebio/platform/path_deploy.py:127–148  ·  view source on GitHub ↗
(path, base)

Source from the content-addressed store, hash-verified

125
126
127def default_index_page(path, base):
128 urlpath = path[len(base):] or '/'
129 title = "Index of %s" % urlpath
130 dirs = [] if path == base else [('../', '')] # (name, doc)
131 files = [] # (name, doc)
132 for f in os.listdir(path):
133 if not filename_ok(f):
134 continue
135
136 full_path = os.path.join(path, f)
137 if os.path.isfile(full_path):
138 if f.endswith('.py'):
139 code = open(full_path, encoding='utf8').read()
140 identifiers = identifiers_info(code)
141 if 'main' in identifiers:
142 files.append([f[:-3], identifiers['main']])
143 else:
144 dirs.append([(f + '/'), ''])
145
146 items = dirs + files
147 max_name_width = max([len(n) for n, _ in items] + [0])
148 return _app_list_tpl.generate(files=items, title=title, max_name_width=max_name_width)
149
150
151def get_app_from_path(request_path, base, index, reload=False):

Callers

nothing calls this directly

Calls 3

filename_okFunction · 0.85
identifiers_infoFunction · 0.85
appendMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…