File tree 14 files changed +142
-1
lines changed
14 files changed +142
-1
lines changed Original file line number Diff line number Diff line change 13
13
# limitations under the License.
14
14
15
15
# [START app]
16
+ import logging
16
17
import os
17
18
18
19
from flask import Flask
@@ -57,6 +58,15 @@ def track_example():
57
58
return 'Event tracked.'
58
59
59
60
61
+ @app .errorhandler (500 )
62
+ def server_error (e ):
63
+ logging .exception ('An error ocurred during a request.' )
64
+ return """
65
+ An internal error occurred: <pre>{}</pre>
66
+ See logs for full stacktrace.
67
+ """ .format (e ), 500
68
+
69
+
60
70
if __name__ == '__main__' :
61
71
# This is used when running locally. Gunicorn is used to run the
62
72
# application on Google App Engine. See entrypoint in app.yaml.
Original file line number Diff line number Diff line change 13
13
# limitations under the License.
14
14
15
15
import datetime
16
+ import logging
16
17
import os
17
18
import socket
18
19
@@ -80,6 +81,15 @@ def index():
80
81
# [END example]
81
82
82
83
84
+ @app .errorhandler (500 )
85
+ def server_error (e ):
86
+ logging .exception ('An error ocurred during a request.' )
87
+ return """
88
+ An internal error occurred: <pre>{}</pre>
89
+ See logs for full stacktrace.
90
+ """ .format (e ), 500
91
+
92
+
83
93
if __name__ == '__main__' :
84
94
# This is used when running locally. Gunicorn is used to run the
85
95
# application on Google App Engine. See entrypoint in app.yaml.
Original file line number Diff line number Diff line change 13
13
# limitations under the License.
14
14
15
15
import datetime
16
+ import logging
16
17
import os
17
18
import socket
18
19
@@ -65,6 +66,15 @@ def index():
65
66
# [END example]
66
67
67
68
69
+ @app .errorhandler (500 )
70
+ def server_error (e ):
71
+ logging .exception ('An error ocurred during a request.' )
72
+ return """
73
+ An internal error occurred: <pre>{}</pre>
74
+ See logs for full stacktrace.
75
+ """ .format (e ), 500
76
+
77
+
68
78
if __name__ == '__main__' :
69
79
# This is used when running locally. Gunicorn is used to run the
70
80
# application on Google App Engine. See entrypoint in app.yaml.
Original file line number Diff line number Diff line change 12
12
# See the License for the specific language governing permissions and
13
13
# limitations under the License.
14
14
15
+ import logging
15
16
import os
16
17
import socket
17
18
@@ -58,6 +59,15 @@ def index():
58
59
# [END example]
59
60
60
61
62
+ @app .errorhandler (500 )
63
+ def server_error (e ):
64
+ logging .exception ('An error ocurred during a request.' )
65
+ return """
66
+ An internal error occurred: <pre>{}</pre>
67
+ See logs for full stacktrace.
68
+ """ .format (e ), 500
69
+
70
+
61
71
if __name__ == '__main__' :
62
72
# This is used when running locally. Gunicorn is used to run the
63
73
# application on Google App Engine. See entrypoint in app.yaml.
Original file line number Diff line number Diff line change 13
13
# limitations under the License.
14
14
15
15
# [START app]
16
+ import logging
16
17
import subprocess
17
18
18
19
from flask import Flask
@@ -29,6 +30,15 @@ def fortune():
29
30
# [END example]
30
31
31
32
33
+ @app .errorhandler (500 )
34
+ def server_error (e ):
35
+ logging .exception ('An error ocurred during a request.' )
36
+ return """
37
+ An internal error occurred: <pre>{}</pre>
38
+ See logs for full stacktrace.
39
+ """ .format (e ), 500
40
+
41
+
32
42
if __name__ == '__main__' :
33
43
# This is used when running locally. Gunicorn is used to run the
34
44
# application on Google App Engine. See CMD in Dockerfile.
Original file line number Diff line number Diff line change 13
13
# limitations under the License.
14
14
15
15
# [START app]
16
+ import logging
16
17
import subprocess
17
18
18
19
from flask import Flask
@@ -27,4 +28,14 @@ def fortune():
27
28
output = subprocess .check_output ('/usr/games/fortune' )
28
29
return output , 200 , {'Content-Type' : 'text/plain; charset=utf-8' }
29
30
# [END example]
31
+
32
+
33
+ @app .errorhandler (500 )
34
+ def server_error (e ):
35
+ logging .exception ('An error ocurred during a request.' )
36
+ return """
37
+ An internal error occurred: <pre>{}</pre>
38
+ See logs for full stacktrace.
39
+ """ .format (e ), 500
40
+
30
41
# [END app]
Original file line number Diff line number Diff line change 13
13
# limitations under the License.
14
14
15
15
# [START app]
16
+ import logging
16
17
import os
17
18
18
19
from flask import Flask , render_template , request
@@ -78,6 +79,15 @@ def send_email():
78
79
return 'Email sent.'
79
80
80
81
82
+ @app .errorhandler (500 )
83
+ def server_error (e ):
84
+ logging .exception ('An error ocurred during a request.' )
85
+ return """
86
+ An internal error occurred: <pre>{}</pre>
87
+ See logs for full stacktrace.
88
+ """ .format (e ), 500
89
+
90
+
81
91
if __name__ == '__main__' :
82
92
# This is used when running locally. Gunicorn is used to run the
83
93
# application on Google App Engine. See entrypoint in app.yaml.
Original file line number Diff line number Diff line change 12
12
# See the License for the specific language governing permissions and
13
13
# limitations under the License.
14
14
15
+ import logging
15
16
import os
16
17
17
18
from flask import Flask
@@ -42,6 +43,15 @@ def index():
42
43
# [END example]
43
44
44
45
46
+ @app .errorhandler (500 )
47
+ def server_error (e ):
48
+ logging .exception ('An error ocurred during a request.' )
49
+ return """
50
+ An internal error occurred: <pre>{}</pre>
51
+ See logs for full stacktrace.
52
+ """ .format (e ), 500
53
+
54
+
45
55
if __name__ == '__main__' :
46
56
# This is used when running locally. Gunicorn is used to run the
47
57
# application on Google App Engine. See entrypoint in app.yaml.
Original file line number Diff line number Diff line change 15
15
# [START app]
16
16
import base64
17
17
import json
18
+ import logging
18
19
import os
19
20
20
21
from flask import current_app , Flask , render_template , request
@@ -68,6 +69,15 @@ def pubsub_push():
68
69
# [END push]
69
70
70
71
72
+ @app .errorhandler (500 )
73
+ def server_error (e ):
74
+ logging .exception ('An error ocurred during a request.' )
75
+ return """
76
+ An internal error occurred: <pre>{}</pre>
77
+ See logs for full stacktrace.
78
+ """ .format (e ), 500
79
+
80
+
71
81
if __name__ == '__main__' :
72
82
# This is used when running locally. Gunicorn is used to run the
73
83
# application on Google App Engine. See entrypoint in app.yaml.
Original file line number Diff line number Diff line change 13
13
# limitations under the License.
14
14
15
15
# [START app]
16
+ import logging
16
17
import os
17
18
18
19
from flask import Flask , render_template , request
@@ -57,6 +58,15 @@ def send_email():
57
58
# [END example]
58
59
59
60
61
+ @app .errorhandler (500 )
62
+ def server_error (e ):
63
+ logging .exception ('An error ocurred during a request.' )
64
+ return """
65
+ An internal error occurred: <pre>{}</pre>
66
+ See logs for full stacktrace.
67
+ """ .format (e ), 500
68
+
69
+
60
70
if __name__ == '__main__' :
61
71
# This is used when running locally. Gunicorn is used to run the
62
72
# application on Google App Engine. See entrypoint in app.yaml.
Original file line number Diff line number Diff line change 13
13
# limitations under the License.
14
14
15
15
# [START app]
16
+ import logging
17
+
16
18
from flask import Flask , render_template
17
19
18
20
@@ -24,6 +26,15 @@ def hello():
24
26
return render_template ('index.html' )
25
27
26
28
29
+ @app .errorhandler (500 )
30
+ def server_error (e ):
31
+ logging .exception ('An error ocurred during a request.' )
32
+ return """
33
+ An internal error occurred: <pre>{}</pre>
34
+ See logs for full stacktrace.
35
+ """ .format (e ), 500
36
+
37
+
27
38
if __name__ == '__main__' :
28
39
# This is used when running locally. Gunicorn is used to run the
29
40
# application on Google App Engine. See entrypoint in app.yaml.
Original file line number Diff line number Diff line change 13
13
# limitations under the License.
14
14
15
15
# [START app]
16
+ import logging
16
17
import os
17
18
18
19
from flask import Flask , request
30
31
# [START form]
31
32
@app .route ('/' )
32
33
def index ():
33
- """Present the user with an upload form."""
34
34
return """
35
35
<form method="POST" action="/upload" enctype="multipart/form-data">
36
36
<input type="file" name="file">
@@ -68,6 +68,15 @@ def upload():
68
68
# [END upload]
69
69
70
70
71
+ @app .errorhandler (500 )
72
+ def server_error (e ):
73
+ logging .exception ('An error ocurred during a request.' )
74
+ return """
75
+ An internal error occurred: <pre>{}</pre>
76
+ See logs for full stacktrace.
77
+ """ .format (e ), 500
78
+
79
+
71
80
if __name__ == '__main__' :
72
81
# This is used when running locally. Gunicorn is used to run the
73
82
# application on Google App Engine. See entrypoint in app.yaml.
Original file line number Diff line number Diff line change 13
13
# limitations under the License.
14
14
15
15
# [START app]
16
+ import logging
16
17
import os
17
18
18
19
from flask import Flask , request
@@ -73,6 +74,15 @@ def receive_sms():
73
74
# [END receive_sms]
74
75
75
76
77
+ @app .errorhandler (500 )
78
+ def server_error (e ):
79
+ logging .exception ('An error ocurred during a request.' )
80
+ return """
81
+ An internal error occurred: <pre>{}</pre>
82
+ See logs for full stacktrace.
83
+ """ .format (e ), 500
84
+
85
+
76
86
if __name__ == '__main__' :
77
87
# This is used when running locally. Gunicorn is used to run the
78
88
# application on Google App Engine. See entrypoint in app.yaml.
Original file line number Diff line number Diff line change @@ -63,6 +63,16 @@ def index():
63
63
return render_template ('index.html' , external_ip = external_ip )
64
64
# [END app]
65
65
66
+
67
+ @app .errorhandler (500 )
68
+ def server_error (e ):
69
+ logging .exception ('An error ocurred during a request.' )
70
+ return """
71
+ An internal error occurred: <pre>{}</pre>
72
+ See logs for full stacktrace.
73
+ """ .format (e ), 500
74
+
75
+
66
76
if __name__ == '__main__' :
67
77
print ("""
68
78
This can not be run directly because the Flask development server does not
You can’t perform that action at this time.
0 commit comments