This commit is contained in:
50
src/app.py
Normal file
50
src/app.py
Normal file
@ -0,0 +1,50 @@
|
||||
#!/usr/bin/env python3
|
||||
import logging
|
||||
import sentry_sdk
|
||||
from flask import Flask
|
||||
from flask_restful import Api
|
||||
from sentry_sdk.integrations.flask import FlaskIntegration
|
||||
|
||||
from config import SENTRY_DSN, RELEASE_ID, RELEASEMODE, PORT, DEBUG
|
||||
from resources import *
|
||||
|
||||
"""
|
||||
Main Flask RESTful API
|
||||
"""
|
||||
|
||||
__author__ = "@tormakris"
|
||||
__copyright__ = "Copyright 2019, KSZK"
|
||||
__module_name__ = "app"
|
||||
__version__text__ = "1"
|
||||
|
||||
if SENTRY_DSN:
|
||||
sentry_sdk.init(
|
||||
dsn=SENTRY_DSN,
|
||||
integrations=[FlaskIntegration()],
|
||||
send_default_pii=True,
|
||||
release=RELEASE_ID,
|
||||
environment=RELEASEMODE
|
||||
)
|
||||
|
||||
app = Flask(__name__)
|
||||
api = Api(app)
|
||||
|
||||
formatter = logging.Formatter(
|
||||
fmt="%(asctime)s - %(levelname)s - %(module)s - %(message)s"
|
||||
)
|
||||
|
||||
handler = logging.StreamHandler()
|
||||
handler.setFormatter(formatter)
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
logger.setLevel(logging.DEBUG)
|
||||
logger.addHandler(handler)
|
||||
|
||||
api.add_resource(SampleResource, "/v1/input/sample")
|
||||
|
||||
if __name__ == "__main__":
|
||||
app.run(
|
||||
debug=bool(DEBUG),
|
||||
host="0.0.0.0",
|
||||
port=int(PORT),
|
||||
)
|
Reference in New Issue
Block a user