File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change 1313# limitations under the License.
1414
1515# [START app]
16+ import logging
17+
1618from flask import Flask
1719
1820
@@ -25,6 +27,14 @@ def hello():
2527 return 'Hello World!'
2628
2729
30+ @app .errorhandler (500 )
31+ def server_error (e ):
32+ logging .exception ('An error occurred during a request.' )
33+ return """
34+ An internal error occurred: <pre>{}</pre>
35+ See logs for full stacktrace.
36+ """ .format (e ), 500
37+
2838if __name__ == '__main__' :
2939 # This is used when running locally. Gunicorn is used to run the
3040 # application on Google App Engine. See entrypoint in app.yaml.
Original file line number Diff line number Diff line change 1313# limitations under the License.
1414
1515# [START app]
16+ import logging
17+
1618from flask import Flask
1719
1820
2325def hello ():
2426 """Return a friendly HTTP greeting."""
2527 return 'Hello World!'
28+
29+
30+ @app .errorhandler (500 )
31+ def server_error (e ):
32+ logging .exception ('An error occurred during a request.' )
33+ return """
34+ An internal error occurred: <pre>{}</pre>
35+ See logs for full stacktrace.
36+ """ .format (e ), 500
2637# [END app]
You can’t perform that action at this time.
0 commit comments