This repository has been archived on 2020-09-24. You can view files and clone it, but cannot push or open issues or pull requests.
consumer-api/consumer_api/app.py

42 lines
1.1 KiB
Python
Raw Permalink Normal View History

2020-03-29 17:08:53 +02:00
#!/usr/bin/env python3
import sentry_sdk
2020-05-08 20:08:43 +02:00
from sentry_sdk.integrations.flask import FlaskIntegration
2020-03-29 17:08:53 +02:00
from flask import Flask
import os
from db import redis_client
from views import ConsumersView, LogView, SyncView
"""
Main Flask RESTful API
"""
__author__ = "@tormakris"
__copyright__ = "Copyright 2020, GoldenPogácsa Team"
__module_name__ = "app"
__version__text__ = "1"
2020-05-08 20:08:43 +02:00
# Setup sentry
SENTRY_DSN = os.environ.get("SENTRY_DSN")
if SENTRY_DSN:
sentry_sdk.init(
2020-05-08 21:04:13 +02:00
dsn = SENTRY_DSN,
integrations = [FlaskIntegration()],
send_default_pii = True,
release = os.environ.get('RELEASE_ID', 'test'),
environment = os.environ.get('RELEASEMODE', 'dev')
2020-05-08 20:08:43 +02:00
)
2020-03-29 17:08:53 +02:00
app = Flask(__name__)
app.config['REDIS_URL'] = os.environ['REDIS_URL']
2020-03-29 18:12:16 +02:00
app.config['LOCAL_UUID'] = os.environ['LOCAL_UUID']
2020-05-08 19:44:42 +02:00
app.config['CUSTOMER_TIMEOUT'] = int(os.environ.get('CUSTOMER_TIMEOUT', 30))
app.config['PRODUCER_TIMEOUT'] = int(os.environ.get('PRODUCER_TIMEOUT', 60))
2020-03-29 17:08:53 +02:00
redis_client.init_app(app)
for view in [ConsumersView, LogView, SyncView]:
2020-05-08 21:04:13 +02:00
view.register(app, trailing_slash = False)
2020-03-29 17:08:53 +02:00
if __name__ == "__main__":
2020-05-08 21:04:13 +02:00
app.run(debug = True)