Unable to serve index.html at the route "/"
Open
Nobody has claimed this yet.
bug
- Dominant language
- Python
- Stars
- 838
- Forks
- 123
- Avg merge
- 7h 58m
- Merged PRs (30d)
- 12
Description
The following doesn't work, returning a file not found error.
@app.route("/")
def root(request):
return File("index.html")
The following works
@app.route("/index.html")
def root(request):
return File("index.html")
And this also works
@app.route("/")
def root(request):
return "Hello"
This is a failing test that I think illustrates the problem
def test_staticRoot_noBranch(self):
"""
The following should return the contents of the file index.html
@app.route("/")
def root(request):
return File("index.html")
"""
app = self.app
request = requestMock("/")
@app.route("/")
def root(request):
return File(__file__)
d = _render(self.kr, request)
def _cb(result):
self.assertEqual(request.getWrittenData(),
open(__file__).read())
self.assertEqual(request.finishCount, 1)
d.addCallback(_cb)
return d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the failing test_staticRoot_noBranch test and trace the _render path for a request to "/". Compare it with the working "/index.html" and string-return cases shown in the issue. Done means the test passes and serving File(file) at "/" writes the file contents and finishes the request once.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend, web-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100