2018-07-17 18:57:29 +00:00
|
|
|
"""
|
|
|
|
Example app with minimal configuration.
|
|
|
|
|
|
|
|
Use this as a starting point.
|
|
|
|
"""
|
2022-07-12 11:31:38 +00:00
|
|
|
|
2022-07-15 10:10:10 +00:00
|
|
|
from decouple import config
|
2022-01-17 11:55:42 +00:00
|
|
|
|
2022-04-08 14:52:17 +00:00
|
|
|
from ereuse_devicehub.api.views import api
|
2022-10-14 09:28:53 +00:00
|
|
|
from ereuse_devicehub.billing.views import billing
|
2022-01-17 11:55:42 +00:00
|
|
|
from ereuse_devicehub.config import DevicehubConfig
|
|
|
|
from ereuse_devicehub.devicehub import Devicehub
|
|
|
|
from ereuse_devicehub.inventory.views import devices
|
2022-04-04 11:41:36 +00:00
|
|
|
from ereuse_devicehub.labels.views import labels
|
2022-01-17 11:55:42 +00:00
|
|
|
from ereuse_devicehub.views import core
|
2022-05-11 09:48:53 +00:00
|
|
|
from ereuse_devicehub.workbench.views import workbench
|
2022-01-17 11:55:42 +00:00
|
|
|
|
2022-07-15 10:10:10 +00:00
|
|
|
# from flask_wtf.csrf import CSRFProtect
|
|
|
|
|
|
|
|
|
2022-09-29 14:58:30 +00:00
|
|
|
# from werkzeug.middleware.profiler import ProfilerMiddleware
|
2022-07-12 11:31:38 +00:00
|
|
|
|
|
|
|
|
2022-06-27 09:42:16 +00:00
|
|
|
SENTRY_DSN = config('SENTRY_DSN', None)
|
|
|
|
if SENTRY_DSN:
|
2022-07-15 10:10:10 +00:00
|
|
|
import sentry_sdk
|
|
|
|
from sentry_sdk.integrations.flask import FlaskIntegration
|
|
|
|
|
2022-06-27 09:42:16 +00:00
|
|
|
sentry_sdk.init(
|
|
|
|
dsn=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,
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2022-01-17 11:55:42 +00:00
|
|
|
app = Devicehub(inventory=DevicehubConfig.DB_SCHEMA)
|
|
|
|
app.register_blueprint(core)
|
|
|
|
app.register_blueprint(devices)
|
2022-04-04 11:41:36 +00:00
|
|
|
app.register_blueprint(labels)
|
2022-04-08 14:52:17 +00:00
|
|
|
app.register_blueprint(api)
|
2022-05-11 09:48:53 +00:00
|
|
|
app.register_blueprint(workbench)
|
2022-10-14 09:28:53 +00:00
|
|
|
app.register_blueprint(billing)
|
2018-07-17 18:57:29 +00:00
|
|
|
|
2022-01-17 11:55:42 +00:00
|
|
|
# configure & enable CSRF of Flask-WTF
|
|
|
|
# NOTE: enable by blueprint to exclude API views
|
|
|
|
# TODO(@slamora: enable by default & exclude API views when decouple of Teal is completed
|
2022-07-12 09:39:27 +00:00
|
|
|
# csrf = CSRFProtect(app)
|
2022-04-04 10:35:32 +00:00
|
|
|
# csrf.protect(core)
|
|
|
|
# csrf.protect(devices)
|
2022-07-12 09:39:27 +00:00
|
|
|
# app.config["SQLALCHEMY_RECORD_QUERIES"] = True
|
|
|
|
# app.config['PROFILE'] = True
|
|
|
|
# app.wsgi_app = ProfilerMiddleware(app.wsgi_app, restrictions=[30])
|
|
|
|
# app.run(debug=True)
|