Is there a way to make 404 Not Found more verbose?

93 views
Skip to first unread message

Jim Karsten

unread,
Aug 25, 2022, 9:07:31 PM8/25/22
to py4web
Still being new to py4web, often I get a 404 Not Found page. There is nothing logged but the access log. It would be helpful if there was a way to get some verbose output so I can troubleshoot the problem faster. Is there any way to do that?

I have logging working and python exceptions log fine with a Traceback, so those types of issues give me something to work with. It's primarily problems with routing and actions that are head scratchers because of the lack of info.

Any help appreciated.
Thanks,
Jim

Massimo DiPierro

unread,
Aug 25, 2022, 10:20:03 PM8/25/22
to Jim Karsten, py4web
usually you get 404 because the module that defines the page was not loaded. this happens when you have an import error. ot would be logged at startup.

--
You received this message because you are subscribed to the Google Groups "py4web" group.
To unsubscribe from this group and stop receiving emails from it, send an email to py4web+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/py4web/d39b42d0-2029-4c92-bf4a-3456fbb9be67n%40googlegroups.com.

Jim Steil

unread,
Aug 26, 2022, 8:23:47 AM8/26/22
to py4web
hey Jim, can you post some code?  I'll be around the next 8 hours or so and can help out

-Jim

Jim Karsten

unread,
Jan 17, 2023, 9:17:57 PM1/17/23
to py4web
Sorry for the late response. 

I could post some code but it's spread over multiple files.
Besides I've got 404s multiple times and it is going to happen again in the future. 
I'd like a more "teach me how to fish" answer if possible instead of solutions for a specific situation.

Generally a 404 means the request is not found. If my code has syntax errors causing an import errors, that's not a 404 issue, is it? 
Seems confusing to raise 404 on that. Even so, could it not produce a ticket with a Traceback which would make troubleshooting it so much simpler?

I'm seeing lots of promise with py4web, but my progress is so darn slow since whenever I do something incorrect, I'm blind to what the problem is, and end up wasting a lot of time chasing red herrings.

Currently I use the tickets in the dashboard, and check the logs in /var/log/py4web.log. Is there anything else I should be doing?

Any suggestions appreciated,
Jim

Alexander Beskopilny

unread,
Jan 17, 2023, 9:55:50 PM1/17/23
to py4web

We can use our own 404-message interceptor and
handle such messages  with redirect

Here is example of such processing of 404-messages from several applications

( Of course all 404 messages can be written to their own log file )

Jim Steil

unread,
Jan 17, 2023, 10:07:58 PM1/17/23
to py4web
Jim - as with your other post that Massimo answered, I'm guessing it has to do with the same thing, not having the proper @action() setup.

What is the endpoint you're trying to access and what does the relevant @action() look like.

-Jim

Alex Glaros

unread,
Jan 18, 2023, 12:40:17 AM1/18/23
to py4web
would help me also as I can't guess where to start looking.  As Massimo says, it's often an import error but would help if error message would point out what is missing or send me more precise information.

Massimo

unread,
Jan 18, 2023, 1:03:46 AM1/18/23
to py4web
Problem is that if something is not defined there is no way for py4web to know where it is supposed to be defined. py4web cannot distinguish a missing declaration in the code from a typo in the url.

At this time, when you get an a 404 and you do not expect it, my best advice is look at the "routes" section in the _dashboard app. It will tell you exactingly which routes are defined in which file. So if a route is defined and get a 404 then you have typo in the URL. If it is not defined where you expect you should look for tickets or typos in that file. If the file is not mentioned at all, then it is not imported.

Py4web cannot give this information in the 404 because it should not expose its guts to the generic visitor.

Anyway, I will be thinking more about this and maybe we can do better. I am curious if other frameworks have a better way to deal with this particular situation.
One thing I am considering is having the dashboard expose a full console log but not sure it would help in this particular case.

Massimo

Jim Karsten

unread,
Jan 18, 2023, 5:53:07 PM1/18/23
to py4web
Understood. Thanks, Massimo. I wasn't aware I could click the rows in the _dashboard area for more info. That should help.
Cheers,
Jim

Reply all
Reply to author
Forward
0 new messages