librelist archives

« back to archive

404 response for static file that is actually there

404 response for static file that is actually there

From:
Josh Klein
Date:
2012-05-28 @ 20:19
Hello,

I am having an odd issue that has left me at a loss for how to even proceed
with debugging, so I'm hoping this list can point me in the right direction.

I'm running the flask development web server locally with the reloader. I
have been serving static images from ./static/img/ without issue. Recently
(I haven't been able to narrow down the specific commit just yet), new
static files added to the static directory cannot be served. Instead, the
GET gets a 404 response. I say "new files" because I am able to duplicate
an existing file in that directory which is being successfully served with
a 200 response, change the name, and the new file will not be served.

My first thought was caching (browser or server), but I've cleared all the
caches and restarted everything several times over. But maybe I'm missing
something that is caching?

My second thought was permissions, but the permissions match the files that
are being served with a 200 response (and wouldn't that give a 5xx response
anyway?).

Profile - Flask 0.8 on virtualenv with requests installed (otherwise
fresh), on OS X 10.7.3. Making HTTP requests via Chrome 19.0.1084.52.

Thank you for your help.

Regards,
Josh

Re: [flask] 404 response for static file that is actually there

From:
Steven Kryskalla
Date:
2012-05-28 @ 21:58
On Mon, May 28, 2012 at 1:19 PM, Josh Klein <josh@lambdafoundry.com> wrote:
> My first thought was caching (browser or server), but I've cleared all the
> caches and restarted everything several times over. But maybe I'm missing
> something that is caching?

Have you added any routes recently with a pattern that might be
matching the static URLs? For example, a catch-all URL route.

My next thought would be to go into flask's static serving code
("send_from_directory" inside "flask/helpers.py") and debug. Inside
that method it does a check if the file exists, so you can examine the
result of that to find out why it's returning a 404.

Re: [flask] 404 response for static file that is actually there

From:
Josh Klein
Date:
2012-05-29 @ 13:48
On Mon, May 28, 2012 at 5:58 PM, Steven Kryskalla <skryskalla@gmail.com>wrote:

> On Mon, May 28, 2012 at 1:19 PM, Josh Klein <josh@lambdafoundry.com>
> wrote:
> > My first thought was caching (browser or server), but I've cleared all
> the
> > caches and restarted everything several times over. But maybe I'm missing
> > something that is caching?
>
> Have you added any routes recently with a pattern that might be
> matching the static URLs? For example, a catch-all URL route.
>
> My next thought would be to go into flask's static serving code
> ("send_from_directory" inside "flask/helpers.py") and debug. Inside
> that method it does a check if the file exists, so you can examine the
> result of that to find out why it's returning a 404.
>

I banged my head against the issue for awhile last night before turning it
in (issue unresolved), then logged back in this morning to find the problem
resolved. I have no idea why it works today. Oy!

I wish I could report back something useful to others, but I haven't been
able to reproduce the issue. If anyone else can reproduce it, please feel
free to get in touch. I really don't know what went wrong (or changed
between then and now)!

- J