Skip to content

Commit fe11886

Browse files
author
Paul Bersch
committed
created a static directory called files with support for file listing
1 parent ddcc57e commit fe11886

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

files/ponies.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<html>
2+
<head>
3+
<title>Page about ponies.</title>
4+
</head>
5+
<body>
6+
Herrow wrld.
7+
</body>
8+
</html>

post.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,14 @@ def ajaxedit(self, id, width, height):
108108
return post.createEditor(width, height)
109109
ajaxedit.exposed = True
110110

111+
@cherrypy.tools.staticdir(root=os.getcwd(), dir='files')
112+
def files(self):
113+
yield '<h2>Browsing directory /files</h2>\n'
114+
for dirpath, dirnames, filenames in os.walk(os.getcwd()+'/files'):
115+
for filename in filenames:
116+
yield '<a href="/files/%s">%s</a>\n' % (filename, filename)
117+
files.exposed = True
118+
111119
def edit(self, post_title, post_body, post_date):
112120
for post in self.posts:
113121
if post.date == post_date:
@@ -121,6 +129,7 @@ def ajaxget(self, id):
121129
return post.createPost(False)
122130
ajaxget.exposed = True
123131

132+
124133
updateConfig()
125134

126135
cherrypy.tree.mount(Blog(), config='post.config')

posts/20080406020312

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
11
This is the title
22
And this is the body. The body of cheese.
3-
Changes are afloat.
4-
5-
Twice are there changes.
6-
7-
And thrice. Thrice truly.
8-
9-
Wahhhh changeeee.
3+
Changes are afloat.

0 commit comments

Comments
 (0)