Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9189775
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:18:39+00:00 2026-06-17T20:18:39+00:00

I’m having a difficult time with CherryPy’s handling of the static files. The problem

  • 0

I’m having a difficult time with CherryPy’s handling of the static files. The problem has to do with the dealing of the URL’s trailing slash. Sometimes the missing slash is added and sometimes it is not: the behavior is unpredictable. I’m convinced there is a bug lurking in there. The bug seems to show up when I add or remove some static files. It looks like there could be an uninitialized variable creating an undetermined state in the function handling the slash. I have put together a minimal application that exhibits the problem (in my machine at least). I’m using CherryPy 3.2.2 under Ubuntu 12.10.

import cherrypy

class Root(object): pass

conf = {
    '/':{
    'tools.staticdir.on': True,
    'tools.staticdir.dir': '/home/bob/www',
    'tools.staticdir.index': 'index.htm',
    'tools.staticdir.debug': True,
    },
}

cherrypy.tree.mount(Root(), '/', config=conf)
cherrypy.engine.start()
cherrypy.engine.block()

My experimental static folder (/home/bob/www) is very simply structured:

/home/bob/www/index.htm         <-- This file is just <html><body>Hello</body></html>
/home/bob/www/dir/index.htm     <-- This files includes a <img src="picture.jpg"> tag in it
/home/bob/www/dir/picture.jpg   <-- Any picture will do

If I browse localhost:8080/dir/, the resulting page displays the image.
If I browse localhost:8080/dir, the resulting page does not display the image.

Any help would be appreciated. Maybe I’m not configuring the app correctly since I’m new to CherryPy.

Thanks,
Bob

P.S. I read already stackoverflow.com/questions/10276060 which has a similar problem but using Routes. I do not use Routes.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T20:18:40+00:00Added an answer on June 17, 2026 at 8:18 pm

    Temporary solution

    The temporary solution shown here requires a small patch to one of the CherryPy source files. I want to thank Felix Bonkoski who told me about it. I did some google searches and found references to it at bitbucket.org/cherrypy/cherrypy/issue/895/.

    Here are the instructions:

    Locate and edit the file static.py (In my Ubuntu machine it was located at /usr/local/lib/python2.7/dist-packages/cherrypy/lib/static.py). Within the function staticdir(), locate the lines below. They are at the end of that function.

     if handled:
        request.is_index = filename[-1] in (r"\/")   <--- Line in question
    

    Edit the line in question so it looks like this:

     if handled:
        request.is_index = True
    

    and save the file.

    At this point I rebooted the computer and CherryPy is now working as I think it should work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
Basically, what I'm trying to create is a page of div tags, each has
I've got a string that has curly quotes in it. I'd like to replace
In my XML file chapters tag has more chapter tag.i need to display chapters
We're building an app, our first using Rails 3, and we're having to build
I have an array which has BIG numbers and small numbers in it. I
I've tracked down a weird MySQL problem to the two different ways I was

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.