-
Notifications
You must be signed in to change notification settings - Fork 121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to serve index.html at the route "/" #41
Comments
I have a similar experience. I thought that returning an absolute path to a file served on / would work, but didn't. Solved it by:
|
This is not a problem unique to klein. Consider the following invocation of twistd's web plugin:
You'll notice that |
Is this addressed by using the same technique as in #59? I.E., something like this:
UPDATE: The technique from #59 seems to work for me: from klein import Klein
from twisted.web.static import File
app = Klein()
@app.route('/', branch=True)
def root(request):
f = File(__file__)
f.isLeaf = True
f.type, f.encoding = 'text/plain', None # force MIME type for browser rendering
return f
if __name__ == '__main__':
app.run('localhost', 8080) |
So, did PR #59 fix this? |
Used the original reporter's code to reproduce this with Klein version 15.1. @dreid: Would you say this is a bug in Klein's code, a quirk that the docs should explain, or neither? |
It's an issue with |
So I'm hearing "the thing to do about it on the Klein side is note it in the docs, then remove the note when it's fixed in Twisted"? I'm inclined to hear that because I'm working on another PR that is about updating and expanding Klein's docs. |
I think that is a worthwhile approach even if @hawkowl or @glyph (or anyone else really) decides to address it in Klein. (Note: I know longer work on Klein due to lack of time and no longer using it in my job.) If someone wanted to make it "just work" the approach would probably be to ask the |
Ah, thanks for clarifying your role—mostly @-mentioned you because you were the last contributor in the thread. Okay, I'll make a note about this behavior in the docs update branch and nudge the @hawkowl about this issue after that PR's sorted. |
Don't ask me why, but that works:
if the two functions does not have the same name, it does not work |
@stibbons I'm not exactly sure why it works, but that is taking advantage of a bug in the way that we look up routes in werkzeug's url_map; it probably won't work forever :). The workaround from @posita up-thread will work fine. Or, perhaps to illustrate the issue more succinctly:
|
In my case I have the same issue. resource.putChild('', File(....)) |
The following doesn't work, returning a file not found error.
The following works
And this also works
This is a failing test that I think illustrates the problem
The text was updated successfully, but these errors were encountered: