This commit is contained in:
19
src/app.py
19
src/app.py
@@ -7,13 +7,14 @@ from sentry_sdk.integrations.flask import FlaskIntegration
|
||||
from sentry_sdk.integrations.sqlalchemy import SqlalchemyIntegration
|
||||
from healthcheck import HealthCheck
|
||||
|
||||
from errorhandlers import register_all_error_handlers
|
||||
from config import *
|
||||
from db import db
|
||||
from jwtman import jwtman
|
||||
from fbcrypt import bcrypt
|
||||
from marshm import ma
|
||||
from healthchecks import health_database_status
|
||||
from resources import SignupApi, LoginApi
|
||||
from resources import SignupApi, LoginApi, UsersApi, UserParameterApi
|
||||
|
||||
"""
|
||||
Main Flask RESTful API
|
||||
@@ -42,15 +43,12 @@ app.config['JWT_SECRET_KEY'] = JWT_SECRET_KEY
|
||||
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
|
||||
|
||||
api = Api(app)
|
||||
health = HealthCheck(app, "/healthz")
|
||||
health = HealthCheck()
|
||||
db.init_app(app)
|
||||
ma.init_app(app)
|
||||
bcrypt.init_app(app)
|
||||
jwtman.init_app(app)
|
||||
|
||||
with app.app_context():
|
||||
db.create_all()
|
||||
|
||||
formatter = logging.Formatter(
|
||||
fmt="%(asctime)s - %(levelname)s - %(module)s - %(message)s"
|
||||
)
|
||||
@@ -65,13 +63,18 @@ logger.addHandler(handler)
|
||||
# api.add_resource(SampleResource, "/sample")
|
||||
api.add_resource(SignupApi, '/api/auth/signup')
|
||||
api.add_resource(LoginApi, '/api/auth/login')
|
||||
api.add_resource(UsersApi, '/api/users')
|
||||
api.add_resource(UserParameterApi, '/api/users/<username>')
|
||||
|
||||
health.add_check(health_database_status)
|
||||
app.add_url_rule("/healthz", "healthcheck", view_func=lambda: health.run())
|
||||
|
||||
register_all_error_handlers(app)
|
||||
|
||||
|
||||
@app.errorhandler(404)
|
||||
def page_not_found(e):
|
||||
return {'status': 'error', 'message': 'page not found'}, 404
|
||||
@app.before_first_request
|
||||
def init_db():
|
||||
db.create_all()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user