-
Notifications
You must be signed in to change notification settings - Fork 2
/
wsgi.py
57 lines (49 loc) · 1.7 KB
/
wsgi.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
from scouting_backend import create_app
# from sentry_sdk.integrations.flask import FlaskIntegration
# import sentry_sdk
import os
#import rollbar
#import rollbar.contrib.flask
from flask import got_request_exception, request, session
from werkzeug.exceptions import InternalServerError
import traceback
import sendgrid
from scouting_backend.helpers import create_message
sg = sendgrid.SendGridAPIClient()
# sentry_sdk.init(
# dsn=os.getenv("SENTRY_DSN"),
# integrations=[
# FlaskIntegration(),
# ],
# # Set traces_sample_rate to 1.0 to capture 100%
# # of transactions for performance monitoring.
# # We recommend adjusting this value in production.
# traces_sample_rate=1.0
# )
app = create_app()
app.config["SECRET_KEY"] = "Nishan_update"
# @app.before_first_request
# def init_rollbar():
# """init rollbar module"""
# rollbar.init(
# # access token
# os.getenv("ROLLBAR_ACCESS_TOKEN"),
# # environment name
# 'production',
# # server root directory, makes tracebacks prettier
# root=os.path.dirname(os.path.realpath(__file__)),
# # flask already sets up logging
# allow_logging_basic_config=False)
# # send exceptions from `app` to rollbar, using flask's signal system.
# got_request_exception.connect(rollbar.contrib.flask.report_exception, app)
@app.errorhandler(Exception)
def handle_500(e):
print("error")
error_tb = traceback.format_exc()
try:
resp = sg.send(create_message(error_tb + str(session) + str(request)))
except Exception as exc:
print(exc)
return app.finalize_request(e, from_error_handler=True)
if __name__ == "__main__":
app.run(port=5001, debug=True)