This commit is contained in:
parent
5d5bb9cd92
commit
a1ee937f32
23
src/app.py
23
src/app.py
@ -35,7 +35,7 @@ if SENTRY_DSN:
|
|||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
app.config[
|
app.config[
|
||||||
'SQLALCHEMY_DATABASE_URI'] = f"postgresql://{POSTGRES_USERNAME}:{POSTGRES_PASSWORD}@{POSTGRES_HOSTNAME}:5432/{POSTGRES_DB}"
|
'SQLALCHEMY_DATABASE_URI'] = f"postgresql://{POSTGRES_USERNAME}:{POSTGRES_PASSWORD}@{POSTGRES_HOSTNAME}:5432/{POSTGRES_DB}?sslmode=require"
|
||||||
app.config['EXCHANGE_NAME'] = RABBITMQ_EXCHANGE
|
app.config['EXCHANGE_NAME'] = RABBITMQ_EXCHANGE
|
||||||
app.config['FLASK_PIKA_PARAMS'] = {'host': RABBITMQ_HOST,
|
app.config['FLASK_PIKA_PARAMS'] = {'host': RABBITMQ_HOST,
|
||||||
'username': RABBITMQ_USERNAME,
|
'username': RABBITMQ_USERNAME,
|
||||||
@ -43,32 +43,15 @@ app.config['FLASK_PIKA_PARAMS'] = {'host': RABBITMQ_HOST,
|
|||||||
'port': 5672,
|
'port': 5672,
|
||||||
'virtual_host': '/'}
|
'virtual_host': '/'}
|
||||||
api = Api(app)
|
api = Api(app)
|
||||||
health = HealthCheck(app, "/healthz")
|
health = HealthCheck()
|
||||||
db.init_app(app)
|
db.init_app(app)
|
||||||
ma.init_app(app)
|
ma.init_app(app)
|
||||||
|
|
||||||
with app.app_context():
|
with app.app_context():
|
||||||
db.create_all()
|
db.create_all()
|
||||||
|
|
||||||
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, "/sample")
|
api.add_resource(SampleResource, "/sample")
|
||||||
api.add_resource(SampleParameterResource, '/sample/<tag>')
|
api.add_resource(SampleParameterResource, '/sample/<tag>')
|
||||||
|
|
||||||
health.add_check(health_database_status)
|
health.add_check(health_database_status)
|
||||||
|
app.add_url_rule("/healthz", "healthcheck", view_func=lambda: health.run())
|
||||||
if __name__ == "__main__":
|
|
||||||
app.run(
|
|
||||||
debug=bool(DEBUG),
|
|
||||||
host="0.0.0.0",
|
|
||||||
port=int(PORT),
|
|
||||||
)
|
|
||||||
|
Loading…
Reference in New Issue
Block a user