Forums

Custom error page instead of "Something went wrong"

Is it possible to install a custom error page instead of getting the Python Anywhere "Something went wrong" page?

My users are getting this Python Anywhere page while I do an upgrade of the django app. It would be better to serve a static page in the user's language saying the site is under maintenance.

Tried django-site-maintenance but it doesn't serve the purpose as it requires a running django app which isn't the case during an ongoing upgrade.

Davy

you could build a really simple web app, totally separate from your django app, or a static site even, and while you're doing your upgrades you could switch across to that? You'd need to edit your wsgi file, reload, and then change it back when you're done...

It would be even better (as I did it before) to have a spare html file lying around and change the static mapping to that html file each time my webapp is down for upgrades.

Setting the url to / and directory as /home/USERNANME/websitedown.html would work! (It maps to a file called websitedown.html in your home folder.

yep, that sounds like it'll work!

I like the static file idea but to be sure: is this something that is implemented or just an idea?

Also: I have multiple web apps, so how could 1 file in the home directory control all those apps? Seems we need something more clever being aware of every single webapp being up/down.

It's something that EndenDragon already did.

The html file doesn't control anything. It's the site down notice that is shown. The static file mapping is what's controlling it and that is individual to each web app.

Yep that is indeed correct, I have done it before. I discovered it by accident when scrambling to find ways to show that my website is offline and not have any clients hitting my webapp during the maintenance period.

The static file will be served with a 200 OK status code, which is not a correct representation of the state of your service. Still looking for a way to serve error pages with correct status codes.

That's true, if you want to temporarily return a 503 error or something from your site while you're doing maintenance, unfortunately you'd have to do that from Python code (which would be hard if you were in the process of changing your code).