43 lines
909 B
Python
43 lines
909 B
Python
|
#!/usr/bin/env python3
|
||
|
import os
|
||
|
from flask import Flask
|
||
|
import sentry_sdk
|
||
|
from sentry_sdk.integrations.flask import FlaskIntegration
|
||
|
|
||
|
# import stuff
|
||
|
|
||
|
from utils import register_all_error_handlers
|
||
|
|
||
|
# import views
|
||
|
from views import ClassifyView
|
||
|
|
||
|
|
||
|
# Setup sentry
|
||
|
SENTRY_DSN = os.environ.get("SENTRY_DSN")
|
||
|
if SENTRY_DSN:
|
||
|
sentry_sdk.init(
|
||
|
dsn=SENTRY_DSN,
|
||
|
integrations=[FlaskIntegration()],
|
||
|
send_default_pii=True,
|
||
|
release=os.environ.get('RELEASE_ID', 'test'),
|
||
|
environment=os.environ.get('RELEASEMODE', 'dev')
|
||
|
)
|
||
|
|
||
|
# create flask app
|
||
|
app = Flask(__name__)
|
||
|
|
||
|
# important stuff
|
||
|
app.secret_key = os.environ.get('SECRET_KEY', os.urandom(12))
|
||
|
|
||
|
# register error handlers
|
||
|
register_all_error_handlers(app)
|
||
|
|
||
|
# register views
|
||
|
for view in [ClassifyView]:
|
||
|
view.register(app, trailing_slash=False)
|
||
|
|
||
|
|
||
|
# start debugging if needed
|
||
|
if __name__ == "__main__":
|
||
|
app.run(debug=True)
|