Skip to content

Commit dfcf8dd

Browse files
committed
beautify default index page of path_deploy()
1 parent f056f1a commit dfcf8dd

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

pywebio/platform/path_deploy.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,13 @@ def add_to_path(p):
107107
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
108108
<title>{{ title }}</title>
109109
<meta name="description" content="PyWebIO applications index">
110-
<style>a{text-decoration:none;display:inline-block;min-width:100px}span{color:grey}</style>
110+
<style>a{text-decoration:none;display:inline-block;min-width:{{ max_name_width }}ch}span{color:grey}</style>
111111
</head>
112112
<body>
113113
<h1>{{ title }}</h1>
114114
<hr>
115115
<pre style="line-height: 1.6em; font-size: 16px;">
116-
{% for name,doc in files %} <a href="{{ name }}">{{ name }}</a> <span>{{ doc }}</span>
116+
{% for name,doc in files %} <a href="{{ name }}">{{ name }}</a> <span>{{ doc }}</span>
117117
{% end %}</pre>
118118
<hr>
119119
</body>
@@ -140,7 +140,9 @@ def default_index_page(path, base):
140140
else:
141141
dirs.append([(f + '/'), ''])
142142

143-
return _app_list_tpl.generate(files=dirs + files, title=title)
143+
items = dirs + files
144+
max_name_width = max([len(n) for n, _ in items]+[0])
145+
return _app_list_tpl.generate(files=items, title=title, max_name_width=max_name_width)
144146

145147

146148
def get_app_from_path(request_path, base, index, reload=False):

0 commit comments

Comments
 (0)