K
K
Konstantin Gorodetsky2015-08-29 05:39:38
Python
Konstantin Gorodetsky, 2015-08-29 05:39:38

How to display python script errors in browser window?

I am writing a script for web. When an error occurs, either an error 500 appears or only part of the text is displayed up to the place of the error. You have to run the script in the console to see the error text. How to view debug information in a browser window?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrey Dugin, 2015-09-13
@gorodetskiykp

import cgitb
cgitb.enable()

As mentioned above, it is not recommended to do this on a combat server - expose the script filling to the user.

S
Shmele, 2015-09-09
@shmele

The context is not entirely clear. What do you write and, most importantly, what tools do you use.
But in general try this:

import traceback


try:
    ...ваш код...
except BaseException as error:
    full_traceback = traceback.format_exc()

in full_traceback there will be a text traceback, at the time of the error.
Then take it wherever you want. It already depends on what tools you use.
In general, if we are talking about a combat server, and not a local copy from the developer, then get yourself a Sentry . There is simply no limit to the joy of using it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question